Copied to clipboard

Flag this post as spam?

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


  • Joel 40 posts 62 karma points
    May 27, 2011 @ 15:42
    Joel
    0

    Why isn't my image showing?

    <?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"
            exclude-result-prefixes="msxml umbraco.library">
            <xsl:output method="xml" omit-xml-declaration="yes"/>

            <xsl:param name="currentPage" />
            <xsl:variable name="imageid" select="/macro/imageid" />
            <xsl:variable name="thumbwidth" select="/macro/thumbwidth" />
            <xsl:variable name="align" select="/macro/align" />
            <xsl:variable name="linktoorig" select="/macro/linktoorig" />
            <xsl:variable name="uselightbox" select="/macro/uselightbox" />
            <xsl:variable name="lightboxgroup" select="/macro/lightboxgroup" />
              
            <xsl:template match="/">
              <xsl:if test="$imageid != '' "
                imageid:<xsl:value-of select="$imageid" /><br/>
               thumbwidth: <xsl:value-of select="$thumbwidth" /><br/>
               align: <xsl:value-of select="$align" /><br/>
               linktoorig: <xsl:value-of select="$linktoorig" /><br/>
               uselightbox: <xsl:value-of select="$uselightbox" /><br/>
                lightboxgroup:  <xsl:value-of select="$lightboxgroup" /><br/><br/>
              </xsl:if>
              
              <img src="{umbraco.library:GetMedia($currentPage/imageid,'false')/umbracoFile}" />


            </xsl:template>

    </xsl:stylesheet>

    input:

    <div umb_macroalias="Thumbnail" umb_lightboxgroup="" umb_thumbwidth="100" umb_linktoorig="1" umb_imageid="1091" umb_align="" umb_uselightbox="1" ismacro="true" onresizestart="return false;" umbversionid="4f3d35f6-62fa-4638-a7bd-932c4f68767c" umbpageid="1183" title="This is rendered content from macro" class="umbMacroHolder"><!-- startUmbMacro --> <!-- endUmbMacro --></div>

     

    output variables:

    imageid:/media/330/freighthandling.jpg15011344064jpg
    thumbwidth: 100
    align: 
    linktoorig: 1
    uselightbox: 1
    lightboxgroup:

    However, when adding the <img> tag in the xlst, I'm getting an error: Error parsing XSLT file: \xslt\Thumbnail.xslt

    Why? what goes wrong?


  • Sebastian Dammark 583 posts 1407 karma points
    May 27, 2011 @ 15:47
    Sebastian Dammark
    0

    Try this

    <xsl:template match="/">
      <xsl:if test="$imageid != '' "> 
        imageid:<xsl:value-of select="$imageid" /><br/>
        thumbwidth: <xsl:value-of select="$thumbwidth" /><br/>
        align: <xsl:value-of select="$align" /><br/>
        linktoorig: <xsl:value-of select="$linktoorig" /><br/>
        uselightbox: <xsl:value-of select="$uselightbox" /><br/>
        lightboxgroup:  <xsl:value-of select="$lightboxgroup" /><br/><br/>
        <img src="{umbraco.library:GetMedia($imageid,'false')/umbracoFile}" />
      </xsl:if>
    </xsl:template>
  • Joel 40 posts 62 karma points
    May 27, 2011 @ 16:15
    Joel
    0

    Getting the same error.. :(

  • Joel 40 posts 62 karma points
    May 27, 2011 @ 16:28
    Joel
    0

     

    <img>
                  <xsl:attribute name="src">
                    <xsl:text>ImageGen.ashx?image=</xsl:text>
                    <xsl:value-of select="$imageid"/>
                    <xsl:text>&amp;width=150&amp;height=98%&amp;constrain=true</xsl:text>
                  </xsl:attribute>
                </img>

    Code above works, but it fails on the image url. Instead of "/media/330/freighthandling.jpg", the imageid variable returns:

    "/media/330/freighthandling.jpg15011344064jpg", which ofcourse results in an incorrect url

  • Pasang Tamang 258 posts 458 karma points
    May 27, 2011 @ 16:49
    Pasang Tamang
    0

    Hi Joel

    Did you tried <xsl:value-of select="$imageid/umbracoFile"/>?

    Thanks

    Pnima

  • Joel 40 posts 62 karma points
    May 27, 2011 @ 16:55
    Joel
    0
    <xsl:if test="$imageid != '' "
            
                imageid:<xsl:value-of select="$imageid" /><br/>
                thumbwidth: <xsl:value-of select="$thumbwidth" /><br/>
                align: <xsl:value-of select="$align" /><br/>
                linktoorig: <xsl:value-of select="$linktoorig" /><br/>
                uselightbox: <xsl:value-of select="$uselightbox" /><br/>
                lightboxgroup:  <xsl:value-of select="$lightboxgroup" /><br/><br/>
                          
                <xsl:value-of select="$imageid/umbracoFile"/>
              </xsl:if>

    No error, but <xsl:value-of select="$imageid/umbracoFile"/> didn't gave any result

  • Sebastian Dammark 583 posts 1407 karma points
    May 29, 2011 @ 23:23
    Sebastian Dammark
    0

    Try telling us what you get if you do this:

    <textarea>
      <xsl:copy-of select="$imageid" />
    </textarea>

    It should give you the content of $imageid

     

  • Sean Holmesby 61 posts 82 karma points
    May 30, 2011 @ 03:33
    Sean Holmesby
    0

    Maybe try adding ?umbDebugShowTrace=true onto the end of your url. That way you should be able to get an idea of the error actually being thrown.

    I think the issue is that $imageid won't have what you want in it. You'll want it to be a four digit ID of the image item. Could the issue be the name of the parameter you're passing in is different from what you expect? i.e you pass in umb_imageid="1091" but your expect /macro/imageid".

  • Joel 40 posts 62 karma points
    May 30, 2011 @ 09:07
    Joel
    0

     

    <textarea>
            <xsl:copy-of select="$imageid" />
    </textarea>

    Gives the following results:

    <imageid><Image id="1091" version="a96ae7ea-df9d-45c8-98d4-0ccd0a2b8a8b" parentID="-1" level="1" writerID="0" nodeType="1032" template="0" sortOrder="54" createDate="2011-04-29T10:29:21" updateDate="2011-04-29T10:29:21" nodeName="Freighthandling" urlName="freighthandling" writerName="Joel van Dieren" nodeTypeAlias="Image" path="-1,1091"><umbracoFile>/media/330/freighthandling.jpg</umbracoFile><umbracoWidth>150</umbracoWidth><umbracoHeight>113</umbracoHeight><umbracoBytes>44064</umbracoBytes><umbracoExtension>jpg</umbracoExtension></Image></imageid>

     

  • Sebastian Dammark 583 posts 1407 karma points
    May 30, 2011 @ 10:23
    Sebastian Dammark
    1

    In that case this should work:

    <img src="{$imageid/umbracoFile} alt="" border="0" />
  • Joel 40 posts 62 karma points
    May 30, 2011 @ 10:40
    Joel
    1

    Finally :)

    Sebas: you helped me finding the answer. The following tag returns the image correctly:

    <img src="{$imageid/Image/umbracoFile}" alt="" border="0" />
  • Sebastian Dammark 583 posts 1407 karma points
    May 30, 2011 @ 10:48
    Sebastian Dammark
    1

    Hi Joel

    You might wanna try this package: XML Dump
    It's really great when working with XML/XSLT

  • 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.

Please Sign in or register to post replies