Thanks for the reply. Your code appears to want to loop over all mediaItem's in the current document. Unfortunately, this isnt an option here. I have other properties on the document that are also images. Also I do know that there is only one image here. Is there a way to access as a singular item
Accessing nested properties with razor
I have an image property on my document that ends up getting saved like this in the xml
Using razor, how can I access mainImage/DAMP/mediaItem/Image/umbracoFile?
inside your template or i prefer to use a macro .cshtml write the following:
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach (dynamic c in Model.mediaItem)
{
@: <img src="@c.umbracoFile" alt="" />
}
The @: says that this is Markup code, so don't be irritated by that.
Thats all.
For more details read inside this post http://our.umbraco.org/forum/developers/razor/18993-DAMP-concerned-retrieving-Crop-url-@-Sebastiaan
Greetings
Toni,
Thanks for the reply. Your code appears to want to loop over all mediaItem's in the current document. Unfortunately, this isnt an option here. I have other properties on the document that are also images. Also I do know that there is only one image here. Is there a way to access as a singular item
Okay that's easy. Insert the following code into your template:
<umbrac:Macro language="cshtml" runat="server">
@inherits umbraco.MacroEngines.DynamicNodeContext
@:<img src="@Model.mainImage.mediaItem.Image.umbracoFile" alt="" />
</umbraco:Macro>
Have fun with that piece of code :)
is working on a reply...