Display Image from Media Library in Umbraco 7

后端 未结 8 2151
野性不改
野性不改 2021-02-04 00:22

This should be something embarrassingly simple, but I can\'t get it to work: I\'d simply like to display an image that was uploaded to the Umbraco Media Library (Umbraco 7.1.1)

8条回答
  •  萌比男神i
    2021-02-04 00:54

    Having had such an unexpectedly hard time for something that I would have thought would be easy, this snipped worked for me.

    @if (Model.Content.HasValue("OtherImages"))
    {
       var otherImages = Model.Content.GetPropertyValue>("OtherImages");
       foreach (var image in otherImages)
       {
          if (image != null)
          {
             @image.Name
          }
       }
    }
    

    Much of the other postings did not work for me, but I think that the API has changed a bit. I'm using Umbraco 7.6.1. I'm not sure whether the null check is necessary, but it certainly won't do any harm.

提交回复
热议问题