Copied to clipboard

Flag this post as spam?

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


  • Bartlomiej Barc 7 posts 106 karma points
    Nov 30, 2016 @ 16:23
    Bartlomiej Barc
    0

    Media Picker Field in WebForms Template Umbraco 7.5.3

    Hi,

    I use Umbraco 7.5.3 with a WebForms template. I uploaded an image to Media Content and I try to get it inside the template by:

    <umbraco:image runat="server" field="bannerImage" />
    

    as referenced here: Masterpages - Umbraco Image

    It should output something like:

    <img src="/media/1009/imagename.jpg" />
    

    But what I am finding in my browser is:

    <img src="{src: '/media/1009/imagename.jpg', crops: []}">
    

    The image is not rendered. Can I make it working correctly somehow?

    Thanks.

  • Bartlomiej Barc 7 posts 106 karma points
    Nov 30, 2016 @ 17:52
    Bartlomiej Barc
    100

    Ok. It is solved.

    I went to XSLT and grabbed my image:

    <xsl:variable name="image" select="umbraco.library:GetMedia($imageId,0)"/>
    

    Then converted inner XML of umbracoFile which is apparently JSON to XML:

    <xsl:variable name="mySrc" select="umbraco.library:JsonToXml($image/umbracoFile)"/>
    

    And used it as src attribute:

    <img>
            <xsl:attribute name="src">
                <xsl:value-of select="$mySrc/src" />
            </xsl:attribute> ...
    
Please Sign in or register to post replies

Write your reply to:

Draft