Copied to clipboard

Flag this post as spam?

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


  • Ste 5 posts 11 karma points
    Aug 13, 2013 @ 10:09
    Ste
    0

    Can't retrieve image using MediaPicker

    I am trying to retrieve the url to an image using the GetMedia mediapicker.

    The code below works fine:

        <xsl:for-each select="umbraco.library:GetXmlNodeById(1123)/* [@isDoc]">
                  <article>
                    <img width="1822" height="600">
                      <xsl:attribute name="src">
                        <xsl:value-of select="umbraco.library:GetMedia(1139, 0)/umbracoFile" />
                      </xsl:attribute>
                    </img>
                    <div class="contents">
                      <h1>
                        <xsl:value-of select="bannerHeading1"/>
                      </h1>
                      <h2>
                        <xsl:value-of select="bannerHeading2"/>
                      </h2>
                    </div>
                  </article>
                </xsl:for-each>

    However, if I replace the key line with this:

        <xsl:value-of select="umbraco.library:GetMedia(bannerImage, 0)/umbracoFile" />


    I get a parsing error. 

    Is there a way I can pass in the property I want?  The value of "bannerImage" is 1139 as I want it to be.

  • Ste 5 posts 11 karma points
    Aug 13, 2013 @ 17:32
    Ste
    0

    For anyone else trying to get an image from an item in a content folder, this is how I got it to work:

    <xsl:for-eachselect="umbraco.library:GetXmlNodeById(1123)/* [@isDoc]"><article><!-- Store the ID --><xsl:variablename="mediaId"select="bannerImage"/><!-- Check the ID is numeric --><xsl:iftest="number($mediaId) &gt; 0"><xsl:variablename="mediaNode"select="umbraco.library:GetMedia($mediaId, false())"/><xsl:iftest="string-length($mediaNode/umbracoFile) &gt; 0"><imgsrc="{$mediaNode/umbracoFile}"width="1822"height="600"/><divclass="contents"><h1><xsl:value-ofselect="bannerHeading1"/></h1></div></xsl:if></xsl:if></article></xsl:for-each>

    You first need to check that the value is numeric and then, the bit that was failing me, you need to add the "/umbracoFile" part to your media node variable.

Please Sign in or register to post replies

Write your reply to:

Draft