This is being used when dragging images into a content area. It enables you to easily customized the rendering
Tank you. So you do not use this when rendering images on a page outside a content area?
When rendering an images as a property on a page, a display template is used by default. Check out Image.cshtml under DisplayTemplates in the alloy project
When i look at Index.cshtml for ProductPage i see an image beeing rendered like this:
<div @Html.EditAttributes(x => x.CurrentPage.PageImage)>
<img src="@Url.ContentUrl(Model.CurrentPage.PageImage)"/>
</div>
Why is there an <img> here if you should use image.cshtml? Is not the display template used here? If not, is there an example where it is used?
The display template is not used there. It would have been had you typed @Html.PropertyFor(x => x.CurrentPage.PageImage).
This is done in JumbtronBlockWide.
The way it has been done in ProductPage could be useful if you want to render your image a bit different than normally, but do not want to create a new display template to do that.
One more question about this:
How do i set the alt text to the Copyright property from the image when the image.cshtml look like this?
@model EPiServer.Core.ContentReference
@if (Model != null)
{
<img src="@Url.ContentUrl(Model)" alt="" />
}
In the Alloy MVC project there is a model, partial view and controller for a image file. But it's never used when rendering images on the site? Why not if so?
Cheers
David