@{ var img = Model.MediaById(Model.Thumbnail); // you could also make a check to see if an image has been choose if(!String.IsNullOrEmpty(@Model.Thumbnail)){ <a href="@img.Url">@img.Name</a> } }
I received the following below for the following line:
var img =Model.MediaById(Model.Thumbnail);
CS1061: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'MediaById' and no extension method 'MediaById' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
This error occured for an MVC template in Umbraco 4.10beta
Umbraco 4.10 Razor - Getting image from media picker
Hi I've just downloaded and installed Ubmraco 4.10. So far so good, my only issue is how do we get media?
I've chosen an image with a media picker and now want to show that in my Razor view. I tried:
but with no luck
Hi Matthew,
Try something like,
Hi Fuji,
I received the following below for the following line:
CS1061: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'MediaById' and no extension method 'MediaById' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
This error occured for an MVC template in Umbraco 4.10beta
For anyone who is interested, I have solved this in another post.
http://our.umbraco.org/forum/core/general/35714-Fetching-a-media-item-properties-?p=0
Try this inline razor macro to display a single image...
<umbraco:Macro runat="server" language="cshtml">
<img src="@Library.MediaById(Model.YourPropertyAlias).umbracoFile" alt"@Library.MediaById(Model.YourPropertyAlias).nodeName">
</umbraco:Macro>
Thanks, Sahan
is working on a reply...