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 ?
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./R
I use the AllowedTypes attribute on a content reference that is used to select image.
@Robin: I was hoping to avoid re-inventing something which "existed" in CMS6
@Daniel: as originally stated, the property type is Url, not ContentReference.
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.