Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • yousif 5 posts 95 karma points
    Jul 05, 2021 @ 14:08

    Working with Media Picker

    Hello There, I'm new to Umbraco and I'm trying to use media picker on my site but for some reason the value is always null or empty.

    I followed the steps in here but when inspecting the html code i get the following results:

    <img class="img-fluid" src="" style="background-image: url('')" alt="">

    Here is my code:

    Layout = "Master.cshtml";
    var image = Model.Value<IPublishedContent>("mainImage");
    if (image != null)
    <img src="@image.Url" class="img-fluid" style="background-image: url('@image')" alt="" />
    }  }

    In the Backoffice i added my image in Media first and i did click save and publish. enter image description here

    I'm running on version 8.14.1

  • Brendan Rice 487 posts 848 karma points
    Jul 08, 2021 @ 12:23
    Brendan Rice

    Hi Yousif,


    <img src="@image.Url()" class="img-fluid" style="background-image: url('@image.Url()')" alt="" />
  • Huw Reddick 533 posts 1723 karma points
    Jul 08, 2021 @ 13:40
Please Sign in or register to post replies

Write your reply to: