Try our conversational search powered by Generative AI!

Friendly url for Blob in edit mode

Vote:
 

Hi

I've started to look into the Blob property type in 7.5. I have a class ImageFile extending ImageData where i have created a new Blob property ListThumbnail with set width and height. I also have a Block Type where I want to print all images listed on the blocks own content folder using my ListThumbnail representation of the image. However I can not find a nice way to get the correct url. I have tried to get the url for the ImageFile and then just append /ListThumbnail to that in the template. This works in preview mode but in edit mode this results in an url wich looks like 'http://localhost:3603/epiui/CMS/Content/contentassets/en-US/1aba9e3b9f584226b43e52648555e065/banner-2.jpg,,305?epieditmode=False/ListThumbnail' wich obviously does not give me the image size I want. 

Is there any other way to route the Blob's url or is my only option to use some ugly string handling to remove the query from the url in edit mode?

Thanks

#86372
May 20, 2014 14:20
Vote:
 

You can change how the url should be rendered by changing the context mode:

UrlResolver.Current.GetUrl(SomeContentReference, null, new VirtualPathArguments() { ContextMode = ContextMode.Default });

By using the "default" mode, the link will be rendered as if you were in view mode, even if you are in edit mode

#86375
May 20, 2014 14:42
Vote:
 

Simple as that... Thank you :)

#86378
May 20, 2014 15:26
Vote:
 

Here is some code that you can use that will make sure that the context not being forced to default/view. The reason that you want to keep the context when displaying images is that images requested through the editorial URL is not cached, so when an editor uploads a new image this will bypass the browser/server caches and thus give less confusion for the editors:

var routeValues = new RouteValueDictionary();
routeValues["action"] = "Thumbnail";

var url = UrlResolver.Current.GetUrl(CurrentPage.SomeImageReference, null, new VirtualPathArguments() { RouteValues = routeValues });
#86600
May 26, 2014 13:23
Vote:
 

Thank you Linus. The images are not displayed as properties in the editorial view though. Would the cachning still affect the output of the image listing?

#86708
May 28, 2014 18:48
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.