I use Orchard CMS 1.10.1
. I'm overriding View of a summary display type
of a content type, for this, I need url of image field in display type summary.
I can get the image url itseft this way :
@Model.ContentItem.Product.Images.FirstMediaUrl
This is part of the view altenate:
<div class="col-sm-4">
<img [email protected] />
</div>
My question is how can I get url of summary of this image? So I can replace the above url with the summary one.
You can do it like this:
@{
var image = Model.ContentItem.Product.Images.MediaParts.First();
}
<div class="col-sm-4">
@Display(BuildDisplay(image, "Summary"))
</div>
You need to display it like this because Image
in Orchard is a content item, but if you want to display image url inline with resizing you can do the following:
@{
var imageUrl = Model.ContentItem.Product.Images.FirstMediaUrl;
}
<div class="col-sm-4">
<img src="@Display.ResizeMediaUrl(Width: 200, Height: 200, Mode: "crop", Alignment: "middlecenter", Path: imageUrl)" />
</div>