Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I know I could create my own custom Property Editor value converter for DAMP, but just wondering if there is an easier way to signal that my DAMP picker should use the value converter for a standard media picker?
I have upgraded some media pickers to DAMP and as they are single item pickers, I would like the following call to return a typed media object, as they do when they are a media picker:
var media = Model.Content.GetPropertyValue<IPublishedContent>("prop");
Even if this was a fallback in the DAMP value converter, this would be good.
I don't really understand what you did. If you want to use the value converter just use the DAMP Property Editor Value Converter. What do you mean with fallback and default media pickers? If you want a single item with DAMP you can do:
var media =Model.Content.GetPropertyValue<DAMP.PropertyEditorValueConverter.Model>("prop").First;
Then you can do media.Url and things like that.
Hi Jeroen - the DAMP property editors will only be single pickers so I just implemented a Value Converter in the same way as a standard media picker in the end. This standardises the project code a little bit better. Cheers for the alternative solution anyway!
public class GenericDampPickerPropertyEditorValueConverter : IPropertyEditorValueConverter
string _propertyTypeAlias = string.Empty;
string _docTypeAlias = string.Empty;
public bool IsConverterFor(Guid propertyEditorId, string docTypeAlias, string propertyTypeAlias)
_propertyTypeAlias = propertyTypeAlias;
_docTypeAlias = docTypeAlias;
public Attempt<object> ConvertPropertyValue(object value)
int nodeId; //check value is node id and not stored as node names
if (UmbracoContext.Current != null && int.TryParse(value.ToString(), out nodeId))
var umbHelper = new UmbracoHelper(UmbracoContext.Current);
IPublishedContent mediaPickerContent = null;
if (uQuery.GetUmbracoObjectType(nodeId) == uQuery.UmbracoObjectType.Media)
mediaPickerContent = umbHelper.TypedMedia(value.ToString());
return new Attempt<object>(true, mediaPickerContent);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted