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
Im trying to use the Imagegen to display an image but gets trouble in xslt:
<xsl:variable name="GenImage"> /umbraco/imageGen.aspx?image=<xsl:value-of select="$FullImage" />&height=400&height=400&constrain=true </xsl:variable>
<xsl:value-of select="$GenImage" disable-output-escaping="yes"/>
The & is displayed as & and not as &!!I cant just write "&" because xslt complains.
The reason why im not wrapping this up in an img-tag is because its a javascript that fetches the variable. So I need to just write the url.
What is wrong..?
Weird. When I try adding your code in a macro I get the "&" nicely displayed.
Showing the whole 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:msxsl="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxsl umbraco.library">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/><xsl:template match="/"><xsl:value-of select="umbraco.library:RegisterStyleSheetFile('Style_tiny', '/css/Style_tiny.css')"/>
<!-- start writing XSLT --><xsl:if test="$currentPage/data [@alias = 'galImages'] != ''"><div id="imageList"><xsl:variable name="images" select="number($currentPage/data [@alias = 'galImages'])"/><xsl:variable name="bigW" select="number($currentPage/data [@alias = 'bigPicW'])"/><xsl:variable name="bigH" select="number($currentPage/data [@alias = 'bigPicH'])"/>
<xsl:variable name="thumbW" select="number($currentPage/data [@alias = 'thumbW'])"/><xsl:variable name="wrapperH" select="number($currentPage/data [@alias = 'wrapperH'])"/>
<xsl:if test="$currentPage/data [@alias = 'galImages'] != 0"><ul id="slideshow"><xsl:for-each select="umbraco.library:GetMedia($images, 'true')/node"> <xsl:variable name="theNode" select="."/> <xsl:variable name="picFile" select="./data[@alias='umbracoFile']"/> <xsl:variable name="picW" select="./data[@alias='umbracoWidth']"/> <xsl:variable name="picH" select="./data[@alias='umbracoHeight']"/>
<li> <xsl:variable name="FullImage" select="concat(substring-before(data[@alias='umbracoFile'],'.'), '_thumb_800.jpg')"/> <xsl:variable name="GenImage"> /umbraco/imageGen.aspx?image=<xsl:value-of select="$FullImage" />&height=400&constrain=true </xsl:variable> <h3>Rapido</h3> <span><xsl:value-of select="$GenImage" /></span> <p>Exterior</p> <a href="#"> <img> <xsl:attribute name="src">/umbraco/imageGen.aspx?image=<xsl:value-of select="$FullImage"/>&width=<xsl:value-of select="100"/>&height=<xsl:value-of select="75"/>&constrain=true</xsl:attribute> </img> </a> </li></xsl:for-each> </ul></xsl:if> </div> <div id="wrapper"> <div id="fullsize"> <div id="imgprev" class="imgnav" title="Föregående bild"></div> <div id="imglink"></div> <div id="imgnext" class="imgnav" title="Nästa bild"></div> <div id="image"></div> <div id="information"> <h3></h3> <p></p> </div> </div> <div id="thumbnails"> <div id="slideleft" title="Scrolla vänster"></div> <div id="slidearea"> <div id="slider"></div> </div> <div id="slideright" title="Scrolla höger"></div> </div> </div><xsl:value-of select="umbraco.library:RegisterJavaScriptFile('Compressed', '/scripts/compressed.js')"/><script type="text/javascript"> //$(document).ready(function()//$(function(){ $('slideshow').style.display='none'; $('wrapper').style.display='block'; var slideshow=new TINY.slideshow("slideshow"); window.onload=function(){ slideshow.auto=true; slideshow.speed=100; slideshow.link="linkhover"; slideshow.info=""; slideshow.thumbs="slider"; slideshow.left="slideleft"; slideshow.right="slideright"; slideshow.scrollSpeed=15; slideshow.spacing=5; slideshow.active="#fff"; slideshow.init("slideshow","image","imgprev","imgnext","imglink"); }
}//});</script></xsl:if>
</xsl:template>
</xsl:stylesheet>
This actually is not a problem, using & in a URL is perfectly valid.
The only problem I always have with building a variable like this is that sometimes this:
Turns into this:
<xsl:variable name="GenImage"> /umbraco/imageGen.aspx?image= <xsl:value-of select="$FullImage" /> &height=400&height=400&constrain=true </xsl:variable>
And then you get line breaks in the URL, which most browsers don't handle to well, so I wrap the string into <xsl:text> blocks:
<xsl:variable name="GenImage"> <xsl:text>/umbraco/imageGen.aspx?image=</xsl:text> <xsl:value-of select="$FullImage" /> <xsl:text>&height=400&height=400&constrain=true</xsl:text> </xsl:variable>
Anyway, my ImageGen URL's look exactly the same as yours, including the & notation and they work just fine.
Look at this link:http://www.eabussar.se/umbraco/imageGen.aspx?image=/media/8145/hp 001 kopia_thumb_800.jpg&height=400&constrain=true
The image is not 400 high but if i strip the & and replace with & then it works?
New link....http://www.eabussar.se/umbraco/imageGen.aspx?image=/media/8313/exterior_thumb_800.jpg&height=400&constrain=true
I have this problem too, though I've been using image gen for many different projects, so maybe it's been a long day.
If you follow froads link above the image is not resized until you change the 'amp' in FF, Chrome & IE.
Any ideas?
Rich
Kinda answering my own question (yes, it's been a long day)
The images get resized correctly when they are called within html, but not when the image url is used directly in a browser.
Anyone know a work around for this and a way to get '&' into XSLT?
Here's a solution if anyone needs it
&
Usage like this
/umbraco/imagegen.ashx?image=/media/2979/Crowd_1841.jpg&width=200
Might be a better way but works for me.
Editing my post killed the code, so here it is again (not talking to myself...)
<xsl:text disable-output-escaping="yes">&</xsl:text>
<img> <xsl:attribute name="src">/umbraco/imagegen.ashx?image=/media/2979/Crowd_1841.jpg<xsl:text disable-output-escaping="yes">&</xsl:text>width=200</xsl:attribute> </img>
Ok, ignore me, seems that the above doesn't work either, time to quit for the day.
Ok, this should do it
<xsl:variable name="image"> <xsl:text><img src='/umbraco/imageGen.aspx?image=</xsl:text> <xsl:value-of select="$url" /> <xsl:text>&height=200&width=200&constrain=true'/></xsl:text> </xsl:variable> <xsl:value-of select="$image" disable-output-escaping="yes"/>
Wow really glad I found this post. Just what I was looking for. Thank you!
Jeroen
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Allowing & as &
Im trying to use the Imagegen to display an image but gets trouble in xslt:
The & is displayed as & and not as &!!
I cant just write "&" because xslt complains.
The reason why im not wrapping this up in an img-tag is because its a javascript that fetches the variable. So I need to just write the url.
What is wrong..?
Weird. When I try adding your code in a macro I get the "&" nicely displayed.
Showing the whole code:
This actually is not a problem, using & in a URL is perfectly valid.
The only problem I always have with building a variable like this is that sometimes this:
Turns into this:
And then you get line breaks in the URL, which most browsers don't handle to well, so I wrap the string into <xsl:text> blocks:
Anyway, my ImageGen URL's look exactly the same as yours, including the & notation and they work just fine.
Look at this link:
http://www.eabussar.se/umbraco/imageGen.aspx?image=/media/8145/hp 001 kopia_thumb_800.jpg&height=400&constrain=true
The image is not 400 high but if i strip the & and replace with & then it works?
New link....
http://www.eabussar.se/umbraco/imageGen.aspx?image=/media/8313/exterior_thumb_800.jpg&height=400&constrain=true
I have this problem too, though I've been using image gen for many different projects, so maybe it's been a long day.
If you follow froads link above the image is not resized until you change the 'amp' in FF, Chrome & IE.
Any ideas?
Rich
Kinda answering my own question (yes, it's been a long day)
The images get resized correctly when they are called within html, but not when the image url is used directly in a browser.
Anyone know a work around for this and a way to get '&' into XSLT?
Rich
Here's a solution if anyone needs it
Usage like this
Might be a better way but works for me.
Rich
Editing my post killed the code, so here it is again (not talking to myself...)
Here's a solution if anyone needs it
Usage like this
Might be a better way but works for me.
Rich
Ok, ignore me, seems that the above doesn't work either, time to quit for the day.
Ok, this should do it
Rich
Wow really glad I found this post. Just what I was looking for. Thank you!
Jeroen
is working on a reply...