skip to Main Content

how to display image from my Document Type (Category) info Templates view?

I tried to insert value but i get this

Umbraco.Cms.Core.Models.MediaWithCrops`1[Umbraco.Cms.Web.Common.PublishedModels.Image]
    
    

Can someone help?

2

Answers


  1. If you have a MediaWithCrops type (which it looks like you do) you can use the following:

    NameOfMediaWithCropsVariable.MediaItem.MediaUrl();
    
    Login or Signup to reply.
  2. For developers looking to display images in a loop:

    @foreach (var item in selection)
    {
        var picture = item.Value<IPublishedContent("postImage").GetCropUrl();
        <div class="thumbnail-img" style="background-image:url(@picture)"></div>
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search