XSL to display an image from a File (single) field in a data node
Author:Annj
Last Updated:October 06, 2017 1:01 PM
In this case there are two data fields in the schema. This example is from data detail xsl, also works in datail listing xsls.
- The image (a file single field) - SystemLogo
- The alt text (a text 1 line field) - SystemLogoAltText
Using a fieldProcessor - because we are combining different data fields - and we are checking there is content to display (the if test).
<xsl:template match="SystemLogo" mode="fieldProcessor">
<xsl:param name="StyleNode" />
<xsl:param name="Node" />
<xsl:if test="normalize-space($Node/SystemLogo)!=''">
<span class="systemLogo"><img src="{$Node/SystemLogo}" alt="{$Node/SystemLogoAltText}"/></span>
</xsl:if>
</xsl:template>