Try our conversational search powered by Generative AI!

Get Full File Path of ImageFile

Vote:
 

Hi all,

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:

Image

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?

#88687
Jul 25, 2014 2:47
Vote:
 

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.

http://www.markeverard.com/2014/02/13/image-resizing-in-episerver-7-5-cms/

#88689
Jul 25, 2014 8:33
Vote:
 

Hi Johan,

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.

http://world.episerver.com/Code/Martin-Pickering/ImageResizingNet-integration-for-CMS75/

Thanks for your help!

#88711
Jul 28, 2014 0:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.