I've recently switched to MVC for my templates, and I'm having a bit of trouble finding how to do things that I was able to do in Razor scripts inside of Web Forms. I read that the Umbraco helper is used for most things now that Library was being used for in the scripts.
I've got it where I can grab content and get their properties, but I'm having trouble getting Media. I'm getting the node right (I believe) with this code:
var featuredImage = Umbraco.Media(CurrentPage.FeaturedImage);
The FeaturedImage piece of the CurrentPage is selected from a media picker and is returning the Id to the media. I can't figure out how to get the URL to that image so I can display it in an img element. I've tried Umbraco.NiceUrl(featuredImage), featuredImage.Url, featuredImage.NiceUrl(), and the only thing I've gotten back from those is either a hash or a blank.
MVC Umbraco helper
Hey everyone,
I've recently switched to MVC for my templates, and I'm having a bit of trouble finding how to do things that I was able to do in Razor scripts inside of Web Forms. I read that the Umbraco helper is used for most things now that Library was being used for in the scripts.
I've got it where I can grab content and get their properties, but I'm having trouble getting Media. I'm getting the node right (I believe) with this code:
The FeaturedImage piece of the CurrentPage is selected from a media picker and is returning the Id to the media. I can't figure out how to get the URL to that image so I can display it in an img element. I've tried Umbraco.NiceUrl(featuredImage), featuredImage.Url, featuredImage.NiceUrl(), and the only thing I've gotten back from those is either a hash or a blank.
How do you get a URL to media in MVC?
2 things, add umbracoFile to the Umbraco.Media call. Also, make sure that CurrentPage.FeaturedImage returns a string or an int (and not HtmlString)
is working on a reply...