Try our conversational search powered by Generative AI!

URL To Picture in CMS 9


In EPiServer 6 there is a property type called URL To Picture which maps to the Url-class in EPiServer 9 but there is no built in UIHint which works with this.

In order to limit the selection of the file to an internal picture however one would assume that UIHint.Image could be used on the property, this however fails because UIHint.Image has a targettype of ContentReference. It is possible to use the Url, UIHint.Image combination but this fails in on page-editing with a dreadful exception. 

Does anyone know of any workarounds for this in CMS 9 to make this work properly  ? 

Apr 13, 2016 9:06

You could always create your own DisplayTemplate/UIHint, and make it work with your property, just make sure to pass in your property type instead of ContentReference, you'll probably have to make some changes tho, take a look at the current UIHint.Image display template and figure out a way from there.


Apr 13, 2016 11:22
Apr 13, 2016 14:21

@Robin: I was hoping to avoid re-inventing something which "existed" in CMS6

@Daniel: as originally stated, the property type is Url, not ContentReference.

Apr 14, 2016 9:46

Yup, I know. What I meant is that it might be worth switching to the new way after 7.5. 7.5+ has a completely new way of handling media files using ContentReference instead of the old url way. You will likely run into more problems in the future than this one. 

New property for storing contentreference, adjust rendering, migrate to new property with a scheduled job that converts the old url to contentreference =>solved. 

Or build support for allowedtypes attribute yourself using the IValidate interface...? Shouldn't be too tricky. I don't know of a way out of the box right now though. 

Apr 14, 2016 10:14
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.