Quantcast
Channel: Joel Abrahamsson
Viewing all articles
Browse latest Browse all 78

Display template for images when using EPiServer CMS and ASP.NET MVC

$
0
0

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=""/>
}

Viewing all articles
Browse latest Browse all 78

Trending Articles