Copied to clipboard

Flag this post as spam?

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


  • ddjak 5 posts 95 karma points
    Dec 03, 2018 @ 15:09
    ddjak
    0

    Can't show image in Nested Content

    Hello everyone,

    New to Umbraco and I started using Nested Content. It's really convenient!

    I am able to render strings, but not images from the content/doc types. It shows the value as null even though I've put an image in the BackOffice. Would love if there is something obvious I'm missing.

    Here's the code:

    @inherits UmbracoTemplatePage
    @{
        IEnumerable<IPublishedContent> items = Umbraco.AssignedContentItem.GetPropertyValue<IEnumerable<IPublishedContent>>("showProducts");
        foreach (var item in items)
        {
            string title = item.GetPropertyValue<string>("productName");
            string price = item.GetPropertyValue<string>("price");
            var photo = item.GetPropertyValue<IPublishedContent>("photos");
            <h3>@title</h3>
            <h3>@price</h3>
            <h3>@photo</h3>
            //<div style="background-image:url('@(photos)');"></div>
            //<img src="@(Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("photos").Url)" />
            <img src="@photo.Url" height="200" width="200" alt="@item.Name"/>
            }
        }
    

    I've tried a few other ways to no avail. I feel I'm missing something in terms of the connection to the images uploaded in nested content for the specific current page.

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Dec 03, 2018 @ 15:20
    Dave Woestenborghs
    0

    Hi ddjak,

    What do you get when you output @photo.Name ?

    And is the "photos" the correct property type alias. And what picker are you using ?

    Dave

  • ddjak 5 posts 95 karma points
    Dec 03, 2018 @ 15:46
    ddjak
    100

    I fixed it!

    Turns out it had everything to do with the Media Picker. I disabled multiple image uploads and it worked like a charm!

    Thanks!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies