Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]><xsl:stylesheetversion="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="/"><img><xsl:attribute name="src">/umbraco/imageGen.ashx?image=/<xsl:value-of select="test"/>&width=89&height=147</xsl:attribute><xsl:attribute name="alt">0</xsl:attribute></img></xsl:template></xsl:stylesheet>
Instead of outputting the image it just outputs the hardcoded html:
<img alt="0" src="/umbraco/imageGen.ashx?image=/&width=89&height=147">
How do i get this to work?
Hey Daniel,
In order to access the data fra a page you need to use the param <xsl:param name="currentPage"/>. In your example it would look something like this:
<img>
<xsl:attribute name="src">
/umbraco/imageGen.ashx?image=/<xsl:value-of select="$currentPage/test"/>&width=89&height=147
</xsl:attribute>
<xsl:attribute name="alt">0</xsl:attribute>
</img>
However this would not display your image either, this would only output the id of the image.
In order to get the url of your image, you need to use this extension: umbraco.library:GetMedia
Try using this example:
<xsl:variable name="image" select="umbraco.library:GetMedia($currentPage/test,'false')/umbracoFile" />
/umbraco/imageGen.ashx?image=/<xsl:value-of select="$image"/>&width=89&height=147
First i save the image url in a variable called "image". Then i use this variable to when generating the image "src".
/Thor
Thanks Thor, I made something similar now, had to make macro recursive also so found a nice post (old) post by Neehouse..
Is it best practice to make variables or is it just preference ? :)
I'm not sure if it's best practice, but i find them nice to use :-)
Hi Daniel
I consider making variables best practice. It saves some calls, which is good for performance.
/Jan
Thanks guys :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Display image via xslt Umbraco 4.5.2
<?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="/">
<img>
<xsl:attribute name="src">/umbraco/imageGen.ashx?image=/<xsl:value-of select="test"/>&width=89&height=147</xsl:attribute>
<xsl:attribute name="alt">0</xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>
Instead of outputting the image it just outputs the hardcoded html:
<img alt="0" src="/umbraco/imageGen.ashx?image=/&width=89&height=147">
How do i get this to work?
Hey Daniel,
In order to access the data fra a page you need to use the param <xsl:param name="currentPage"/>. In your example it would look something like this:
<img>
<xsl:attribute name="src">
/umbraco/imageGen.ashx?image=/<xsl:value-of select="$currentPage/test"/>&width=89&height=147
</xsl:attribute>
<xsl:attribute name="alt">0</xsl:attribute>
</img>
However this would not display your image either, this would only output the id of the image.
In order to get the url of your image, you need to use this extension: umbraco.library:GetMedia
Try using this example:
<xsl:variable name="image" select="umbraco.library:GetMedia($currentPage/test,'false')/umbracoFile" />
<img>
<xsl:attribute name="src">
/umbraco/imageGen.ashx?image=/<xsl:value-of select="$image"/>&width=89&height=147
</xsl:attribute>
<xsl:attribute name="alt">0</xsl:attribute>
</img>
First i save the image url in a variable called "image". Then i use this variable to when generating the image "src".
/Thor
Thanks Thor, I made something similar now, had to make macro recursive also so found a nice post (old) post by Neehouse..
Is it best practice to make variables or is it just preference ? :)
I'm not sure if it's best practice, but i find them nice to use :-)
Hi Daniel
I consider making variables best practice. It saves some calls, which is good for performance.
/Jan
Thanks guys :)
is working on a reply...