Here's the Razor example (note the @crops.Find in there), this assumes that your DAMP picker has an alias of "media" and that you store the media XML in your umbraco.config:
<h2>@Model.Name</h2>
<h3>Digibiz Advanced Media Picker</h3>
@{
if (Model.HasValue("Media")) {
dynamic mediaItems = Model.Media.mediaItem;
if (mediaItems.Count() != 0)
{
<ul>
@foreach (var item in mediaItems)
{
var image = item.Image;
<li>
Original image: <a href="@image.umbracoFile">@image.nodeName</a> (@image.umbracoBytes bytes)<br />
@*
If the type of the mediacropper is not XML (but a string) then there
are no crops defined, so I should not try to find the crops.
*@
@{ var crops = image.mediaCropper; }
@if (crops.GetType().ToString() != "System.String")
{
<text>Crops:</text><br />
<img src="@crops.Find("@name", "Thumbnail").url" alt="@image.nodeName"/><br />
<img src="@crops.Find("@name", "Header").url" alt="@image.nodeName"/>
}
</li>
}
</ul>
}
}
}
Get images with a specific cropping ?
Well ... how do I do that ?
It's fairly easy in XSLT but I just can't seem to figure it out in Razor.
Here is my XSLT example:
Did you have a look at the Cultiv Razor Examples project? It also has some cropping examples.
Jeroen
Here's the Razor example (note the @crops.Find in there), this assumes that your DAMP picker has an alias of "media" and that you store the media XML in your umbraco.config:
Don't you need to defend against the crops not existing?
What if Find() returns nothing?
is working on a reply...