Copied to clipboard

Flag this post as spam?

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


  • Hasan Khan 7 posts 97 karma points
    May 01, 2018 @ 18:21
    Hasan Khan
    0

    Getting image to render from partial view using blender package

    Hi all,

    So i created grid editor called profile card using leblender and one of the property is an image. I create a partial view for it , here is the code block.

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    @using Umbraco.Web.Templates
    
    
    
    @foreach(var item in Model.Items)
    {
    
    <div class="media d-block media-custom text-center">
       <img src=" @Umbraco.TypedMedia(item.GetValue<string>("image")).Url">
        <div class="media-body">
            <h3 class="mt-0 text-black">@item.GetValue("name")</h3>
            <p>@item.GetValue("description")</p>
            <p>
                <a href="mailto:@item.GetValue("contactDetails")" class="p-2"><span class="fa fa-envelope-o"></span></a>
    
            </p>
        </div>
    </div>
    

    }

    When I publish the page it gives me Object reference not set to an instance of an object error.

    I have used the same code in img src to render an image but it was in umbraco 7.5.13 currently i am using 7.7.

    Am I missing something or gone way off? Please help I would really appreciate that :)

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    May 01, 2018 @ 18:29
    Alex Skrypnyk
    0

    Hi Hasan

    Replace image rendering with code below:

    <img src="@item.GetPropertyValue<IPublishedContent>("image")).Url">
    

    It can be a solution.

    Thanks,

    Alex

  • Hasan Khan 7 posts 97 karma points
    May 01, 2018 @ 19:56
    Hasan Khan
    0

    Hi Alex, thank you for the reply I have used the line of code in my partial view but i get this error now

    enter image description here

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    May 01, 2018 @ 20:42
    Alex Skrypnyk
    0

    Hi Hasan

    At which line do you have this error?

  • Hasan Khan 7 posts 97 karma points
    May 01, 2018 @ 20:57
    Hasan Khan
    0

    On that img tag line , here is the code snippet

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft