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'm doing this...
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "Page.cshtml"; var img = Umbraco.Media(Model.Content.GetPropertyValue("homeHeroImage")).UmbracoFile; } <img src="@img" />
@img is null for some reason. When I check homeHeroImage it's returning the correct media item id. What am I missing?
Hi Bh
Use this code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "Page.cshtml"; var img = Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("homeHeroImage")).Url; } <img src="@img" />
Ha. I just found this documentation. But, you beat me to it. Thanks as always Alex!
https://our.umbraco.org/documentation/getting-started/Backoffice/Property-Editors/Built-in-Property-Editors/Media-Picker
Assuming homeHeroImage is a media picker you should use:
var img = Model.Content.GetPropertyValue<IPublishedContent>("homeHeroImage").Url;
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Media Not Rendering
I'm doing this...
@img is null for some reason. When I check homeHeroImage it's returning the correct media item id. What am I missing?
Hi Bh
Use this code:
Ha. I just found this documentation. But, you beat me to it. Thanks as always Alex!
https://our.umbraco.org/documentation/getting-started/Backoffice/Property-Editors/Built-in-Property-Editors/Media-Picker
Assuming homeHeroImage is a media picker you should use:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.