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) > 0"><xsl:variablename="mediaNode"select="umbraco.library:GetMedia($mediaId, false())"/><xsl:iftest="string-length($mediaNode/umbracoFile) > 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.
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.
For anyone else trying to get an image from an item in a content folder, this is how I got it to work:
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.is working on a reply...