I want to display an image from a media picker, my document type has several media pickers defined and I would like to use the same macro to dislplay the image for each one. I have a macro parameter for alias called propertyAlias which I use to pass in the name of the media picker. But the xslt does not like the variable being used, see: Unexpected token '$' in the expression what am I doing wrong please?
select parameter causing errors
I want to display an image from a media picker, my document type has several media pickers defined and I would like to use the same macro to dislplay the image for each one. I have a macro parameter for alias called propertyAlias which I use to pass in the name of the media picker. But the xslt does not like the variable being used, see: Unexpected token '$' in the expression what am I doing wrong please?
<xsl:param name="currentPage"/>
<xsl:variable name="propertyAlias" select="//macro/propertyAlias" />
<xsl:template match="/">
<xsl:value-of select="$propertyAlias"/>
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/$propertyAlias, 0)/umbracoFile" />
<xsl:if test="$media">
<img src="{$media}" />
</xsl:if>
</xsl:template>
Hi Andrew,
May be this will help you, i havent tested it but i think it should get you workin
Hi,
To fix that error you should remove the second $ sign from $currentPage/$propertyAlias
If you want to use a variable field name, you can do:
Also, if you get more errors (value too small...) you might need to wrap the GetMedia call in a test to make sure you have a value, ie:
-Tom
is working on a reply...