Great if its working.... Well the only difference is I made the checked for the media in theitself. So whenever it contains a media it will also add the link instead of having the link present all the time.
Remember to mark this thread as solved for others who might need.
Associate images from subnodes on page
The code below shows subnodes images on the page. However, it breaks whenever i dont associate an image with a subnode.
I think i need an if statement, but i dont know how to dot it.
Please advise me.
<xsl:param name="currentPage"/>
<xsl:variable name="field" select="/macro/field" />
<xsl:template match="/">
<xsl:apply-templates select="$currentPage/mediaItem[normalize-space()]" />
</xsl:template>
<xsl:template match="mediaItem">
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia(., false())" />
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<div id="centerimg">
<xsl:if test="$mediaNode/umbracoFile">
<img class="latest_img" border="none" src="{$mediaNode/umbracoFile}" alt="{@nodeName}" width="200" height="160"/>
</xsl:if>
</div>
</a>
</li>
</xsl:for-each>
</xsl:template>
Best regards
Klaus
Hi Klaus,
Are you trying to get the image from the media section or by associating the image to the page node by using media picker?
If you are using the medie picker to choose an image from the media section you could try this
<xsl:variable name="mediaFolder" select="$currentPage"/>
Thank you so much - it worked perfectly.
Acutally, it worked for a second and then it broke. Could you please explain again. I rewrote according to your reply.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:issuu="urn:issuu"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets issuu ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:apply-templates select="$currentPage/mediaItem[normalize-space()]" />
</xsl:template>
<xsl:template match="mediaItem">
<xsl:variable name="mediaFolder" select="$currentPage"/> <li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="mediaItem!= ''">
<img src="{umbraco.library:GetMedia(mediaItem, 'true')/umbracoFile}"/>
</xsl:if>
</a>
</li>
</xsl:template>
</xsl:stylesheet>
Hi Klaus what do you mean by it broke?...the image was displayed and then disappeared? Can you try to
<xsl:template match="/">
Fantastic, that worked very well... What is the difference between the two snippets you gave?
/Klaus
Great if its working.... Well the only difference is I made the checked for the media in theitself. So whenever it contains a media it will also add the link instead of having the link present all the time.
Remember to mark this thread as solved for others who might need.
//fuji
is working on a reply...