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
Hi
I'm trying to display the Url of media that is selected from the media picker in the parent of the current page, but it is always blank.
This returns the correct Id of the media item:
var mainImage = Model.Content.Parent.GetPropertyValue("mainImage");
But when I try and get the Url it's doesn't return anything:
var imageUrl = @Umbraco.Media(mainImage).Url;
Thanks for any help.
Hi James,
If you are using Umbraco v7.6 then you should be able to do this:
var mainImageUrl = Model.Content.Parent.GetPropertyValue<IPublishedContent>("mainImage").Url;
If you are on a version before v7.6 then it should be like this:
var mainImage = Model.Content.Parent.GetPropertyValue<int>("mainImage"); var imageUrl = Umbraco.TypedMedia(mainImage).Url;
Jeavon
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get Url of media picker item of parent.
Hi
I'm trying to display the Url of media that is selected from the media picker in the parent of the current page, but it is always blank.
This returns the correct Id of the media item:
But when I try and get the Url it's doesn't return anything:
Thanks for any help.
Hi James,
If you are using Umbraco v7.6 then you should be able to do this:
If you are on a version before v7.6 then it should be like this:
Jeavon
is working on a reply...