but i have problems with this xsl: <xsl:if test="$mediaNode/umbracoFile"> <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" /> </xsl:if>
this is not working: alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}"
Have you tried to see what XMl you get returned by making a <textarea> with a copy of the variable to see what XML gets returned? If so could you please post the XML in here?
ok, what i get out is: <File id="1053" version="0c10ba34-4fb5-4b66-8cfa-25f40fc0e90b" parentID="1052" level="2" writerID="0" nodeType="1033" template="0" sortOrder="1" createDate="2011-02-02T14:03:51" updateDate="2011-02-02T14:03:50" nodeName="xxx_logo" urlName="xxx_logo" writerName="admin" nodeTypeAlias="File" path="-1,1052,1053"><umbracoFile>/media/44/xxx_logo.jpg</umbracoFile><umbracoExtension>jpg</umbracoExtension><umbracoBytes>21194</umbracoBytes></File>
images via xsl
i have the latest version og umbraco installed.
but i have problems with this xsl:
<xsl:if test="$mediaNode/umbracoFile">
<img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
</xsl:if>
this is not working:
alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}"
i wonder why?
Try placing $mediaNode before the attributes so it knows where to pull them from:
alt="[image]" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}"
still not working...
here is my entire code:
<?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"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="mediaId" select="number($currentPage/logo)" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<img src="{$mediaNode/umbracoFile}" alt="" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Which part isn't working? Is the image showing and the width/height attributes just aren't getting set?
width and height are empty...
Hmm, that should work...try re-saving your image in the Media section?
Otherwise, try outputting the media's XML so we can make sure the values are there:
Hi Amigo
Try refreshing the XML cache by choosing "replublish entire site" by right clicking the node named "Content" in the Content section.
/Jan
hmmm still not working after refresh and resave image....
i really wonder why....
Hi Amigo
Have you tried to see what XMl you get returned by making a <textarea> with a copy of the variable to see what XML gets returned? If so could you please post the XML in here?
/Jan
Hi Jan,
ok, what i get out is:
<File id="1053" version="0c10ba34-4fb5-4b66-8cfa-25f40fc0e90b" parentID="1052" level="2" writerID="0" nodeType="1033" template="0" sortOrder="1" createDate="2011-02-02T14:03:51" updateDate="2011-02-02T14:03:50" nodeName="xxx_logo" urlName="xxx_logo" writerName="admin" nodeTypeAlias="File" path="-1,1052,1053"><umbracoFile>/media/44/xxx_logo.jpg</umbracoFile><umbracoExtension>jpg</umbracoExtension><umbracoBytes>21194</umbracoBytes></File>
Hi Jan,
Now it works, i renamed the image and uploadet a new one....
Thanks a lot both of you ;-)
Hi Amigo
Happy to hear you got it solved. Sometimes stuff just needs to be refreshed one way or the other and booom! it works :-)
Remember to mark the post as solved.
/Jan
is working on a reply...