Don't miss out Virtual Happy Hour today (April 26).
Try our conversational search powered by Generative AI!
AI OnAI Off
Don't miss out Virtual Happy Hour today (April 26).
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
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.
Thanks!