Copied to clipboard

Flag this post as spam?

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


  • Jason C Bitman 4 posts 24 karma points
    Aug 02, 2015 @ 16:58
    Jason C Bitman
    0

    Trying to get the image file link rather than array...

    Folks,

    When getting a media type from one of those fields, this is what I tried, and I am just getting back some sort of struct, and I just need to know how to pull the "src" from it. Any thoughts (aside from, who is this guy?)?

    var mediaItem = Umbraco.TypedMedia(@sponsor.Value.GetPropertyValue("imageFile"));

    <li style="list-style:none;"><a href="@sponsor.Value.GetPropertyValue("link")" target="_blank"><img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@sponsor.Value.GetPropertyValue("linkText")" /></a></li>
    

    It gives me the attached screenshot within the resulting HTML. enter image description here

  • Jason C Bitman 4 posts 24 karma points
    Aug 02, 2015 @ 17:22
    Jason C Bitman
    0

    And so, I figured it out after tons of trial and error. For those looking for the answer, here it is:

    var mediaItem = Umbraco.TypedMedia(@sponsor.Value.GetPropertyValue("imageFile"));
                            <li style="list-style:none;"><a href="@sponsor.Value.GetPropertyValue("link")" target="_blank"><img src="@mediaItem.Url" alt="@sponsor.Value.GetPropertyValue("linkText")" /></a></li>
    

    I just needed to use the referenced media item, and use the .Url property. I find it a bit odd, because object clearly uses "src" as a label for the field I want. A bit counter intuitive, that's all.

    Thanks, and happy coding! Jason

Please Sign in or register to post replies

Write your reply to:

Draft