However im trying to render an image into the produced list that has the alias pageImage. I add the line of code that I have bolded and marked with an arrow and instead of an image rendering i get this.../media/1004/luis.jpg
I just thought it would be a case of adding xsl:value of similar to how i have targeted other umbraco page fields.
Help with rendering images
Hi guys im a complete newbie with xslt but im wondering if anyone could help me.
I have an perfectly good xslt macro that renders a news list like so
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/* [@isDoc]">
<xsl:sort select="@createDate" order="descending"/>
<xsl:if test="position() <= $maxItems">
<li>
<h3>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="pageImage"/> <---------------------------------
<xsl:value-of select="newsHeadline"/>
</a>
</h3>
<p><xsl:value-of select="newsTeaserText" /></p>
<small>Created by: <xsl:value-of select="@writerName"/> on <xsl:value-of select="umbraco.library:LongDate(@createDate)"/> </small>
</li>
</xsl:if>
</xsl:for-each>
However im trying to render an image into the produced list that has the alias pageImage. I add the line of code that I have bolded and marked with an arrow and instead of an image rendering i get this.../media/1004/luis.jpg
I just thought it would be a case of adding xsl:value of similar to how i have targeted other umbraco page fields.
Thanks for the help in advance
Paul
use umbraco.library:getmedia() like this:
<xsl:variablename="media"select="umbraco.library:GetMedia($currentPage/pageImage, 0)"/>
<xsl:iftest="$media">
<xsl:variablename="url"select="$media/umbracoFile"/>
<xsl:variablename="width"select="$media/umbracoWidth"/>
<xsl:variablename="height"select="$media/umbracoHeight"/>
<imgsrc="{$url}"width="{$width}"height="{$height}"/>
</xsl:if>
Depending on what version of the schema your're using the syntax is a little different.
Check out the docs here:
http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
Thanks for your reply niels, I will give it a go and let you know how I do
Paul
is working on a reply...