Display Image from Media Library in Umbraco 7

后端 未结 8 2036
野性不改
野性不改 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条回答
  •  孤独总比滥情好
    2021-02-04 00:57

    Try this

    @if (CurrentPage.Image != null && !(CurrentPage.Image is Umbraco.Core.Dynamics.DynamicNull))
    {
        var m = Umbraco.Media((int)CurrentPage.Image);
    
        @m.UrlName
    }
    

    note: You should cast CurrentPage.Image as int because of Umbraco.Media ambigous constructor

提交回复
热议问题