Copied to clipboard

Flag this post as spam?

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


  • Mov3nforward 47 posts 179 karma points
    Sep 27, 2017 @ 03:06
    Mov3nforward
    0

    Issue with using media picker

    The code below used to work on a few of my previous Umbraco sites with Leblender and now I am seeing an error. What am I missing?

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    
    @{
        Layout = "";
    
        var header = Model.Items.ElementAt(0);
        var image = String.IsNullOrEmpty(header.GetValue<string>("Image")) ? "#" : Umbraco.TypedMedia(header.GetValue<string>("Image")).Url;
        var link = Umbraco.Content( @Model.Items.ElementAt(0).GetValue("link") );
    
    }
    
    
    @if ( @link.Url == "" )
        { <img class='img-responsive @Html.Raw(Model.Items.ElementAt(0).GetValue("class"))' src="@image" data-aos='@Html.Raw(Model.Items.ElementAt(0).GetValue("animationDirection"))' alt='@Html.Raw(Model.Items.ElementAt(0).GetValue("altText"))'> }
    
    else { <a href="@link.Url"> <img class='img-responsive @Html.Raw(Model.Items.ElementAt(0).GetValue("class"))' src="@image" data-aos='@Html.Raw(Model.Items.ElementAt(0).GetValue("animationDirection"))' alt='@Html.Raw(Model.Items.ElementAt(0).GetValue("altText"))'></a> }
    
  • Mov3nforward 47 posts 179 karma points
    Sep 27, 2017 @ 03:13
    Mov3nforward
    0

    I have also tried the example in the leblender documentation.

    @foreach(variteminModel​.​Items​)
    {
    <div>
    <imgsrc="@Umbraco.TypedMedia(item.GetValue​<string>​("image")​).Url"/>
    <h3>@item.GetValue("title")​</h3>
    <p>@item.GetValue("summary")​</p>
    <p><ahref="@Umbraco.TypedContent(item.GetValue​<string>​("link")​).Url">Learnmore</a>
    </p>
    </div>}
    
  • Duncan Bannister 5 posts 76 karma points notactivated
    Oct 06, 2017 @ 12:23
    Duncan Bannister
    0

    Hi Mov3nforward

    Don't you need to pass an int into the @Umbraco.TypedMedia() function ?

    Try :

    <img src="@Umbraco.TypedMedia(item.GetValue<int>("image")).Url"/>
    

    If that does not work. Can you debug the value(i.e item.GetValue

    Hope this helps.

  • Zihadul Azam 26 posts 170 karma points c-trib
    Feb 05, 2018 @ 12:17
    Zihadul Azam
    0

    Hi,

    item.GetValue("image") contanins this string = "Umbraco.Core.Udi[]"

  • Justin RW 8 posts 108 karma points
    Feb 02, 2018 @ 13:57
    Justin RW
    100

    Try passing the Id like this:

    <img src="@Umbraco.TypedMedia(item.GetValue<IPublishedContent>("image").Id).Url"/>
    
Please Sign in or register to post replies

Write your reply to:

Draft