November Happy Hour will be moved to Thursday December 5th.

Default image view

Vote:
 

I need to have a default view that is used for all images when added to a content area, is this possible to have? I know that I can add a view to the DisplayTemplates folder and reference it in the UIhint, but I don't want to restrict the content area to images only, and I would like to have a default behavior for all images. Is this possible?

#154919
Sep 01, 2016 15:51
Vote:
 

Hi!

Just add a view named as your image media type to your ~/Views/Shared folder. If your media type is named ImageMedia the view should be called ImageMedia.cshtml and look something like this:

@model ImageMedia

@if (Model != null)
{
    <img src="@Url.ContentUrl(Model.ContentLink)" alt="">
}
#154920
Edited, Sep 01, 2016 15:57
Vote:
 

Cool, thanks!

#154925
Sep 01, 2016 23:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.