Copied to clipboard

Flag this post as spam?

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


  • Rayyan 46 posts 237 karma points
    Mar 28, 2019 @ 10:06
    Rayyan
    0

    Can't get Media Picker URL (Nested Content)

    Hello Umbraco's Friend, Getting the media picker URL not described in below URL. I have tried many ways but didn't succeed. Could you please help me out.

    https://our.umbraco.com/documentation/getting-started/backoffice/Property-Editors/Built-in-Property-Editors/Nested-Content/

    @{
        var items = Model.Value<IEnumerable<IPublishedElement>>("promoList");
        foreach(var item in items)
        {
        <h1>@(item.Value<string>("PromoCompanyName"))</h1>
        <p>@(item.Value<string>("promoPercentage"))</p>
    
    <img src="@Umbraco.Media(CurrentPage.promoLogoMedia).Url" alt="">
    
        }
    }
    
  • Bjarne Fyrstenborg 1140 posts 3230 karma points MVP 3x c-trib
    Mar 28, 2019 @ 10:26
    Bjarne Fyrstenborg
    100

    Hi Rayyan

    I guess you have an image property in Nested Content element using Media Picker? In that case you can just access the image like the following, where image is the property alias:

    @{
        var items = Model.Value<IEnumerable<IPublishedElement>>("promoList");
        foreach(var item in items)
        {
            var name = item.Value<string>("PromoCompanyName");
            var promoPercentage = item.Value<string>("promoPercentage");
            var image = item.Value<IPublishedContent>("image");
    
            <h1>@name</h1>
            <p>@promoPercentage</p>
    
            if (image != null)
            {
                <img src="@image.Url" alt="">
            }
        }
    }
    

    /Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft