Copied to clipboard

Flag this post as spam?

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

  • Bunnynut 128 posts 310 karma points
    Aug 19, 2019 @ 17:20

    Unable to display image property of childnode

    Hi, on the homepage of my Umbraco v8 website I want to show a list of childnodes from a given parentnode, these items are jobopenings. Each of those childnodes have a property of the type Media. I am having a hard time displaying the image of the childnode.

    This is what I've tried so far:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
            var jobOpenings = Umbraco.Content(Guid.Parse("09fdad92-488c-474f-a8d9-77dfe5f4bd65"))
            .Where(x => x.IsPublished())
            .Where(x => x.IsVisible())
            .Where(x => x.HasProperty("showOnHomepage"))
            .Where(x => (bool)x.GetProperty("showOnHomepage").Value())
            .OrderByDescending(x => x.CreateDate);
    foreach (var jobOpening in jobOpenings)
        //Title shows up
        @jobOpening .Value("title")
        //The following two lines both result in the text "Umbraco.Web.PublishedModels.Image"
        @jobOpening .GetProperty("image").GetValue();
        @jobOpening .Value("image");

    What is the correct way to show the image?

  • Nik 1217 posts 5080 karma points MVP 2x c-trib
    Aug 19, 2019 @ 18:56

    Hey Bunnynut,

    Okay so I would do something like this

    //This is using Models builder models by the way
    foreach(JobOpening jobOpening in jobOpenings) 
         <h2> @jopOpening.Title</h2>
         if(jobOpening.Image != null)
             <img src="@jobOpening.Image.Url"/> 
             //Alternatively use .GetCropUrl() instead of .Url and specify the crop to display



Please Sign in or register to post replies

Write your reply to: