Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    Sep 06, 2011 @ 14:04
    Anthony Candaele
    0

    problem with ImageGen

    Hi,

    For some reason the image is not showing when I include in my Xslt code the querystring parameter for width:

    <img style="float:right;" src="ImageGen.ashx?image={umbraco.library:GetMedia($currentPage/publicationImage, false())/umbracoFile}&amp;width=150" alt="cover image" />

    If I omit the width parameter, my image is rendering on the page

    <img style="float:right;" src="ImageGen.ashx?image={umbraco.library:GetMedia($currentPage/publicationImage, false())/umbracoFile}" alt="cover image" />

    Does anybody know what's going on?

    thanks for your help,

    Anthony Candaele

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 06, 2011 @ 14:19
    Anthony Candaele
    0

    I restate my problem, apparently the image is not rendering with ImageGen altogether. Only if I omit ImageGen.ashx?image= the image is rendered on the page.

  • Rich Green 2246 posts 4008 karma points
    Sep 06, 2011 @ 14:32
    Rich Green
    1

    Hey Anthony,

    Usually I would get the media first then do the imageGen code, something like

     

     <xsl:variable name="mediaId" select="number($currentPage/publicationImage)" />

        <xsl:if test="$mediaId > 0">

            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />

            <xsl:if test="$mediaNode/umbracoFile">

                <img src="imageGen.ashx?image={$mediaNode/umbracoFile}&amp;width={$mediaNode/umbracoWidth}&amp;height={$mediaNode/umbracoHeight}" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" />

            </xsl:if>

        </xsl:if>

     

    Rich

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 06, 2011 @ 14:49
    Anthony Candaele
    0

    Hi Rich,

    That's some clever code. I always checked for an image like this:

    <xsl:if test="string-length(image) &gt; 0">

    <img .... />

    </xsl:if>

    But I guess your code is more robust.

    However, the image still doesn't get rendered. From the moment I omit the ImageGen code the image does get rendered:

    <xsl:if test="$mediaId > 0">
      <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
      <xsl:if test="$mediaNode/umbracoFile">
      <img style="float:right;" src="{$mediaNode/umbracoFile}" alt="cover image" />
      </xsl:if>
    </xsl:if>

    Strange indeed ...

    greetings,
    Anthony

  • Rich Green 2246 posts 4008 karma points
    Sep 06, 2011 @ 14:57
    Rich Green
    1

    Hey,

    What happens if you just call an image using imagegen in the browser, like?

    http://YourDomain.com/imageGen.ashx?image=/media/100/someimage.jpg

    Rich

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 06, 2011 @ 15:02
    Anthony Candaele
    0

    I tried this out and the image gets rendered

  • Rich Green 2246 posts 4008 karma points
    Sep 06, 2011 @ 15:05
    Rich Green
    1

    Can you post the HTML source of the image when you've rendered it via XSLT.

    Rich

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 06, 2011 @ 15:06
    Anthony Candaele
    0

    Hi Rich,

    Problem solved, apparently I had to add a '/' before imageGen.ashx like this:

    src="/imageGen.ashx?image={$mediaNode/umbracoFile}&width=150" alt="cover image" />

    Anyway, thanks for your help, I learned something new from your code for checking the presence of an image node.

    Anthony

  • Rich Green 2246 posts 4008 karma points
    Sep 06, 2011 @ 15:07
    Rich Green
    1

    That'll do it, glad you got it working :)

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft