I am trying to get the URL of an image file with it's file extension.
When I retrieve the URL back using UrlResolver.Current.GetUrl(contentReference.ContentLink) I get the URL to the place where it is sitting in the ContentFolder.
We use the same image over our site with varying sizes of that image. Rather than make the user upload an image for every size we are using an image resizing tool, that takes the url and resizes the picture for the user in each area it is displayed
Our HTML looks like this:
Where @Image is the result of the GetUrl call above.
This works fine with full URLs, but does not work with the ones the GetUrl returns.
Any ideas on what I can do?
You can get the FilePath for a FileBlob (note that this only works for FileBlobProvider, which is the one used by default. It will not work e.g. for AzureBlobProvider) like
var filePath = (ServiceLocator.Current.GetInstance().Get(contentLink).BinaryData as FileBlob).FilePath;
Otherwise you could use additional Blob properties to get scaled sizes of the image, see e.g.
I found another blog post linked in the link you gave me for getting image resizer to play nicely with EPiServer. Which solved all my problems.
Thanks for your help!