sitecoresitecore7media-url

set media url in sitecore 7.x


We have plugin for sitecore that allows content translation. When page is selected to be translated to different language new version of the target language is created and fields are updated with the translated content. We also translate images therefore we have to change image path in the target item or just copy the same url in some cases. Getting the url is quite simple with:

Sitecore.Resources.Media.MediaManager.GetMediaUrl(imageField.MediaItem)

however we cannot determine the way to modify / set this field after MediaPath has been deprecated in sitecore 7. Can anybody come up with suggestions?

Thanks a lot


Solution

  • In order to set/update media url in sitecore 7.x apart from setting mediapath attribute for the image field MediaID has to be set.