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've got an event handler that automatically creates and saves a thumbnail image when the user uploads a PDF to the Media tab in the back office.
The event handler includes code to set the value of a Media Picker field on the original "File" media node, linking it with the automatically generated thumbnail "Image" node.
I've done the same thing a few times in the past, and this has always worked for me:
However, I noticed in the latest version of Umbraco (I'm using 7.7.4), it seems that this is not the way to populate a Media Picker field anymore.
When I try and reference the thumbnail in the front-end views, I get an error something like:
String "1234" is not a valid udi (where 1234 is the node Id of the thumbnail image).
If I save the node manually in the back office, then it fixes the problem (because - I guess - it re-saves the media picker field correctly).
I have come up with a work-around, but I'd rather do it properly in the first place.
So my question is... if its no longer the right thing to just set the Media Picker field value to be a Media Node Id (string or integer), what is the correct way to set it?
You need to do it like this now:
Where contentItem is an IPublishedContent item representing the page and mediaItem is an IMedia item representing the thumbnail image.
The data type for thumbnail needs to be MediaPicker2
See here for an example where I am doing this:
Many thanks for replying, that's done the trick :)
You're welcome Steve.
It's nice to be able to answer one before someone else got in there first :^D
I think it is not needed to create new topic because my problem relates very well to this.
I have also Media Picker but osbolete version which stores int id instead of udi.
I'm setting this Media Picker property during saving event and selected image appears in editor but I have this field set as required and validation still displays that this field is required.
Is there any way to revalidate this property after setting proper value at server side?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted