This task involved developing an user control which will be housed in an custom section and this user control should have option of selecting an image from umbraco server.
I looked at around as to how i can incorporate mediapicker control in my custom user control. I tried using the method suggested in this link, but this control doesnt provide any property which can identify the media file, that was selected.
But this posting, which has a post posted by Jeroen solved my issue. This solution utilizes Mediachooser which has a value property, which gets/sets the media file id.
The solution involves, adding the mediachooser to the placeholder onInit event of the control.
When the user control is submitted for saving, on the post-back, the mediachooser.value contains the value of the media file id.
The following statements will fetch the url for a mediachooser with image selected.
var mediaItem = umbraco.cms.businesslogic.media.Media(Convert.ToInt32(mediaChooserControl.Value))
imageurl = mediaItem.getProperty("umbracoFile").Value.ToString();
No comments:
Post a Comment