Copied to clipboard

Flag this post as spam?

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


  • Jeppe Volander Rasmussen 16 posts 138 karma points
    Aug 15, 2018 @ 09:46
    Jeppe Volander Rasmussen
    0

    Display image from mediapicker

    Hey Guys

    Im simply trying to display an image from a children page to "Glossary", but nothing works. What am i doing wrong?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Glossary>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "Master.cshtml";
    }
    
    @{
        var selection = Model.Content.Site().FirstChild("Glossary").Children()
                            .Where(x => x.IsVisible())
                            .OrderBy("Name");
    }
    
     <div class="row cd-main-content">
    
        @foreach(var item in selection){
          <div class="col-md-3 frontpage-content-block frontpage-content-block--sm divide-me ">
    
            @item.GetPropertyValue("termPhoto").Url
    
            <h2>@item.GetPropertyValue("termHeadline")</h2>
            <p>@item.GetPropertyValue("termDescription")</p>
          </div>
        }
    
    </div><!--row-->
    
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Aug 15, 2018 @ 10:18
    Jan Skovgaard
    0

    Hi Jeppe

    I would say you need an image tag for this line?

        @item.GetPropertyValue("termPhoto").Url
    

    So it becomes

        <img src="@item.GetPropertyValue("termPhoto").Url" alt="" />
    

    I'm assuming that the first line renders an image url of course :)

    /Jan

  • Jeppe Volander Rasmussen 16 posts 138 karma points
    Aug 17, 2018 @ 07:14
    Jeppe Volander Rasmussen
    0

    Doesn't work, it get this error :s

    The best overloaded method match for 'System.Tuple.Create

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Aug 17, 2018 @ 07:47
    Jan Skovgaard
    0

    Hi Jeppe

    Ok, not sure the entire error message was copied over in your last reply?

    But if you just render the @item.GetPropertyValue("termPhoto") without wrapping it in the img tag do you then get the same issue?

    At a first glance at the part of the error message I'm not sure if the error is related to rendering the image though. Does the error disappear if you comment out all the code in your view? If not it's probably caused by something else.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft