Code sample
Display template for images when using EPiServer CMS and ASP.NET MVC
Given you have an URL property with a UI hint to indicate that the editor should select an image, like this:
[UIHint(UIHint.Image)] public virtual Url TopImage { get; set; }
Then you can make it render as an image by placing a partial view in the /Views/DisplayTemplates folder named Image.cshtml with the following content:
@model EPiServer.Url @if (Model != null && !Model.IsEmpty()) { <img src="@Model.ToString()" alt=""/> }
Similar articles
- A first stab at EPiServer CMS with ASP.NET MVC and Page Type Builder
- EPiServer 7 – Content, Pages and Blocks
- How EPiServer's HTML helper PropertyFor works
- EPiServer 7 and MVC – Getting the URL for a page
- EPiMVC – A framework for using EPiServer CMS with ASP.NET MVC
- EPiServer and MVC – Retrieving current page using a custom model binder
- Upgrading a site from EPiServer CMS 6 to EPiServer 7
- Getting started with EPiServer CMS development