I have a bit of a rookie issue. I am using a macro to list elements of subpages on a parent page, and one of the things I pull through is an image via an upload tool on the child pages.
As a shorter alternative that does the same thing...
<img src="{data [@alias='offerImage']}" />
Notice the use of inline expansion with the { }. Basically, whatever you'd put in the select="" xpath of an xsl:value-of can go inside { }... but you can only use the { } inside a tag's attribute. But since that's what you're doing here it works a treat.
There shouldn't be anything that would require escaping in the offerImage property since it is just a path and filename.
Image tag in a macro - rookie question!
Hi folks,
I have a bit of a rookie issue. I am using a macro to list elements of subpages on a parent page, and one of the things I pull through is an image via an upload tool on the child pages.
On the child template I have my syntax like this:
<img src='<umbraco:Item field="offerImage" runat="server"></umbraco:Item>' />
which renders the image.
But on the macro itself, I can only render the image URL using this:
<xsl:value-of select="data [@alias = 'offerImage']" disable-output-escaping="yes"/>
I essentially want to do this on my macro to render the image as opposed to simply the URL:
<img src='<xsl:value-of select="data [@alias = 'offerImage']" disable-output-escaping="yes"/>' />
but there is an error flagged up when I wrap the xsl:value-of in an img tag.
Can anyone help me with the syntax required on the macro to essentially achieve this:
<img src='<xsl:value-of select="data [@alias = 'offerImage']" disable-output-escaping="yes"/>' />
Thanks in advance!
<img>
<xsl:attribute name="src">
<xsl:value-of select="data [@alias = 'offerImage']" disable-output-escaping="yes"/>
</xsl:attribute>
</img>
?
Ooooooooooooooh you legend!
Thanks a lot for that, easiest karma you'll ever earn!
As a shorter alternative that does the same thing...
<img src="{data [@alias='offerImage']}" />
Notice the use of inline expansion with the { }. Basically, whatever you'd put in the select="" xpath of an xsl:value-of can go inside { }... but you can only use the { } inside a tag's attribute. But since that's what you're doing here it works a treat.
There shouldn't be anything that would require escaping in the offerImage property since it is just a path and filename.
cheers,
doug.
Thanks very much for the elaboration. It's helps in understanding the syntax and logic.
is working on a reply...