Copied to clipboard

Flag this post as spam?

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


  • Rik Helsen 670 posts 873 karma points
    Nov 03, 2010 @ 20:22
    Rik Helsen
    0

    Imagegen image used in lightbox appears as raw data instead of an image?

    I have a strange issue... all clues/help appreciated!

    I have a mediapicker property on a page that selects an album in the media section, all images below are listed as thumbs (works nicely), and also shown as a larger version in a lightbox.

    Link to the resized image:

    Screenshot of the same image shown in the lightbox:

     

    xslt 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: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:variable name="mediapickerproperty" select="$currentPage/imageLibrary"/> <!-- datatype property for the mediapicker -->
    <xsl:variable name="bigW" select="700"/> <!-- max width of lightbox popup image in pixels -->
    <xsl:variable name="bigH" select="700"/> <!-- max height of lightbox popup image in pixels -->   
        
    <xsl:template match="/">

      <xsl:if test="$mediapickerproperty &gt; 0">
        <xsl:variable name="images" select="umbraco.library:GetMedia($mediapickerproperty, 1)" />
        <xsl:if test="count($images/*) &gt; 0">
          <xsl:for-each select="$images/*">
       <xsl:if test="./umbracoFile != ''">


    <div class="thumbback">
    <a>
        <xsl:attribute name= "class">fancybox gallery</xsl:attribute>
        <xsl:attribute name= "rel">group</xsl:attribute>

          <xsl:choose>
             <xsl:when test="./umbracoWidth &lt; 700 and ./umbracoHeight &lt; 700">
          <xsl:attribute name= "href">
            <xsl:value-of select="./umbracoFile"/>
            </xsl:attribute>
          </xsl:when>
          <xsl:when test="./umbracoWidth &gt; ./umbracoHeight"> <!-- scale based on height OR width -->
          <xsl:attribute name= "href">
            /umbraco/imageGen.aspx?image=<xsl:value-of select="./umbracoFile"/>&amp;width=<xsl:value-of select="$bigW"/>&amp;constrain=true
            </xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
          <xsl:attribute name= "href">
            /umbraco/imageGen.aspx?image=<xsl:value-of select="./umbracoFile"/>&amp;height=<xsl:value-of select="$bigH"/>&amp;constrain=true
            </xsl:attribute>
          </xsl:otherwise>
        </xsl:choose<!--Small thumbnail -->
            <img src="/umbraco/ImageGen.ashx?image={./umbracoFile}&amp;height=75&amp;width=75&amp;pad=true&amp;bgcolor=ffffff" alt="{./ImgDescription}" title="{./ImgDescription}"/>    
         </a></div>
            </xsl:if>
          </xsl:for-each>
        </xsl:if>
      </xsl:if>

    </xsl:template>

    </xsl:stylesheet>


  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 03, 2010 @ 20:39
    Chriztian Steinmeier
    1

    Woah! ASCII art :-)

    Don't know if it's causing this, but one thing you should be aware of, is the added whitespace you're getting in the href attribute - when you're assembling a value using "mixed content" (text and elements inside an element), as in this:

    <xsl:attribute name= "href">
       /umbraco/imageGen.aspx?image=<xsl:value-of select="./umbracoFile"/>&amp;width=<xsl:value-of select="$bigW"/>&amp;constrain=true
    </xsl:attribute>
    
    The processor really sees this:
    <xsl:attribute name="href"><!-- This is interpreted as significant whitespace
         -->/umbraco/imageGen.aspx?image=<!-- This too!
         --><xsl:value-of select="./umbracoFile"/><!--
         -->&amp;width=<!--
         --><xsl:value-of select="$bigW"/><!--
         -->&amp;constrain=true
    </xsl:attribute>

    Instead, you can do:

    <xsl:attribute name="href">
        <xsl:text>/umbraco/imageGen.aspx?image=</xsl:text>
        <xsl:value-of select="umbracoFile" />
        <xsl:text>&amp;width=</xsl:text>
        <xsl:value-of select="$bigW"/>
        <xsl:text>&amp;constrain=true</xsl:text>
    </xsl:attribute>
    
    Or (my preferred way):
    <xsl:attribute name="href">
        <xsl:value-of select="concat('/umbraco/imageGen.aspx?image=', umbracoFile, '&amp;width=', $bigW, '&amp;constrain=true')" />
    </xsl:attribute>
    
    /Chriztian

     

     

  • Rik Helsen 670 posts 873 karma points
    Nov 03, 2010 @ 20:39
    Rik Helsen
    0

    Nevermind, got it, it's a bug in the newer version of FancyBox, 1.3.1 has issues with images not ending on .jpg

  • Rik Helsen 670 posts 873 karma points
    Nov 03, 2010 @ 20:46
    Rik Helsen
    0

    btw, thanks chriztian for the xslt tutorial :) (I didn't see your remark when i posted the reply above)

    As for the solution in my case,

        'type' : 'image' was not set in the fancybox declaration, and in this newer version of the script it doesn't assume it's an image if the url doesn't end on .jpg or something alike...

    <script type="text/javascript">
    $(document).ready(function() {     

    $("a.fancybox").fancybox({
        'type' : 'image',
        'titlePosition'  : 'over'
      });

    });
    </script>
    </asp:Content>
  • Johan 188 posts 380 karma points
    Feb 07, 2011 @ 16:48
    Johan
    0

    I had this exact problem but with colorbox. There is no way to declare file type in Colorbox so i did a quick-and-dirty-hack. I just added a query string that ended on .jpg at the end.

    "&plzshowmethe=image.jpg"

  • geoff 1 post 22 karma points
    Jul 24, 2013 @ 15:54
    geoff
    1

    dude johan i love you man

     

Please Sign in or register to post replies

Write your reply to:

Draft