Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fredrik Esseen 610 posts 906 karma points
    Dec 07, 2009 @ 15:10
    Fredrik Esseen
    0

    Allowing & as &

    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" />&amp;height=400&amp;height=400&amp;constrain=true 
        </xsl:variable>
    <xsl:value-of select="$GenImage" disable-output-escaping="yes"/>

    The &amp; is displayed as &amp; 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..?

  • Tommy Poulsen 514 posts 708 karma points
    Dec 07, 2009 @ 15:59
    Tommy Poulsen
    0

    Weird. When I try adding your code in a macro I get the "&" nicely displayed.

  • Fredrik Esseen 610 posts 906 karma points
    Dec 07, 2009 @ 16:21
    Fredrik Esseen
    0

    Showing the whole code:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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" />&amp;height=400&amp;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"/>&amp;width=<xsl:value-of select="100"/>&amp;height=<xsl:value-of select="75"/>&amp;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>
  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Dec 07, 2009 @ 16:23
    Sebastiaan Janssen
    1

    This actually is not a problem, using &amp; in a URL is perfectly valid.

    The only problem I always have with building a variable like this is that sometimes this:

    <xsl:variable name="GenImage">
        /umbraco/imageGen.aspx?image=<xsl:value-of select="$FullImage" />&amp;height=400&amp;height=400&amp;constrain=true 
    </xsl:variable>

    Turns into this:

    <xsl:variable name="GenImage">
        /umbraco/imageGen.aspx?image=
        <xsl:value-of select="$FullImage" />
        &amp;height=400&amp;height=400&amp;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>&amp;height=400&amp;height=400&amp;constrain=true</xsl:text>
    </xsl:variable>

    Anyway, my ImageGen URL's look exactly the same as yours, including the &amp; notation and they work just fine.

  • Fredrik Esseen 610 posts 906 karma points
    Dec 08, 2009 @ 09:05
    Fredrik Esseen
    0

    Look at this link:
    http://www.eabussar.se/umbraco/imageGen.aspx?image=/media/8145/hp 001 kopia_thumb_800.jpg&amp;height=400&amp;constrain=true

    The image is not 400 high but if i strip the &amp; and replace with & then it works?

  • Fredrik Esseen 610 posts 906 karma points
    Dec 08, 2009 @ 09:06
  • Rich Green 2246 posts 4008 karma points
    Sep 14, 2010 @ 18:33
    Rich Green
    0

    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

     

     

     

  • Rich Green 2246 posts 4008 karma points
    Sep 14, 2010 @ 18:41
    Rich Green
    0

    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

  • Rich Green 2246 posts 4008 karma points
    Sep 14, 2010 @ 19:07
    Rich Green
    0

    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.

    Rich

  • Rich Green 2246 posts 4008 karma points
    Sep 14, 2010 @ 19:09
    Rich Green
    0

    Editing my post killed the code, so here it is again (not talking to myself...)

    Here's a solution if anyone needs it

    <xsl:text disable-output-escaping="yes">&amp;</xsl:text>

    Usage like this

    <img>
        <xsl:attribute name="src">/umbraco/imagegen.ashx?image=/media/2979/Crowd_1841.jpg<xsl:text disable-output-escaping="yes">&amp;</xsl:text>width=200</xsl:attribute>
    </img>

    Might be a better way but works for me.

    Rich

  • Rich Green 2246 posts 4008 karma points
    Sep 14, 2010 @ 19:28
    Rich Green
    0

    Ok, ignore me, seems that the above doesn't work either, time to quit for the day.

  • Rich Green 2246 posts 4008 karma points
    Sep 14, 2010 @ 20:16
    Rich Green
    1

    Ok, this should do it

    <xsl:variable name="image">
                <xsl:text>&lt;img src='/umbraco/imageGen.aspx?image=</xsl:text>
                <xsl:value-of select="$url" />
                <xsl:text>&amp;height=200&amp;width=200&amp;constrain=true'/&gt;</xsl:text>
    </xsl:variable>
    
    <xsl:value-of select="$image" disable-output-escaping="yes"/>

    Rich

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Apr 12, 2011 @ 14:15
    Jeroen Breuer
    0

    Wow really glad I found this post. Just what I was looking for. Thank you!

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

    Continue discussion

Please Sign in or register to post replies