I know this is a newbie question, but how can I show an image, added with the upload picker in the content editor screen on the final page?
The umbraco:item tag just shows the URL text.
I've tried creating an XSLT macro to do this, but I can't seem to figure out how to pass a variable to the XSLT macro for the URL path. I know I can specify fields in the Macro directly, but I'd rather not do that if possibvle so I don't end up creating lots of XSLT Macros to load all of my image fields.
Thanks Sean - That really set me off well to get this working! For those who are interested here’s the complete solution for a page with simple image display from Upload using both RAZOR and XSLT. First, the XSLT Macro…
To make this work I added a property to the Macro declaration with an alias of ‘imagePath’ and a name of ‘Image Path’. This was the key penny that had failed to drop for me.
Here’s the page template itself, showing the same content twice. Once with RAZOR and once with XSLT. Personally I find the RAZOR syntax a lot more lightweight for this but it’s more personal preference than anything else I guess, as once you have the XSLT Macro you can re-use it anywhere…
How do I show an image?
I know this is a newbie question, but how can I show an image, added with the upload picker in the content editor screen on the final page?
The umbraco:item tag just shows the URL text.
I've tried creating an XSLT macro to do this, but I can't seem to figure out how to pass a variable to the XSLT macro for the URL path. I know I can specify fields in the Macro directly, but I'd rather not do that if possibvle so I don't end up creating lots of XSLT Macros to load all of my image fields.
Here's what I've cobbled together so far...
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="imagePath"/>
<xsl:template match="/">
imagePath = <xsl:value-of select="$imagePath"/><br/>
<xsl:if test="$imagePath != '' ">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="$imagePath" />
</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I think you have to add a little bit to your param to select the parameter being passed in.
<xsl:param name="imagePath" select="/macro/imagePath"/>
Thanks Sean - That really set me off well to get this working! For those who are interested here’s the complete solution for a page with simple image display from Upload using both RAZOR and XSLT. First, the XSLT Macro…
To make this work I added a property to the Macro declaration with an alias of ‘imagePath’ and a name of ‘Image Path’. This was the key penny that had failed to drop for me.
Here’s the page template itself, showing the same content twice. Once with RAZOR and once with XSLT. Personally I find the RAZOR syntax a lot more lightweight for this but it’s more personal preference than anything else I guess, as once you have the XSLT Macro you can re-use it anywhere…
is working on a reply...