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
    yousif
    0

    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 538 posts 1102 karma points
    Jul 08, 2021 @ 12:23
    Brendan Rice
    0

    Hi Yousif,

    try:

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

Write your reply to:

Draft