Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

DisplayTemplates for Image


Using a view in the DisplayTemplates for my images. looks like this:

@model EPiServer.Url
<img src="@Model?width=@ViewData["width"]&height=@ViewData["height"]" />

Using Imageresizer and I wish to use hard typed variables for width and height instead adding it to the ViewData. This is how the view is used:

@Html.PropertyFor(p => p.CurrentPage.Image, new { @width= 50, @height=50})

Is this possible?

Second question. Is it possible to get the Image name from the Url? Using Episerver 7.5 and can't find the right way to do it. 


Apr 29, 2014 9:39

You can create a custom display template Views / Shared / DisplayTemplates / CustomImage.cshtml

@model EPiServer.Url
<img src="@Url.ContentUrl(Model)" width="@ViewBag.width" height="@ViewBag.height"/>


And use it like this from your view:

@Html.DisplayFor(x => x.CurrentPage.Image, "CustomImage", new { width = 50, height = 50 })


But this is not strongly-typed either

Apr 29, 2014 10:22
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.