Copied to clipboard

Flag this post as spam?

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


  • Wade 43 posts 159 karma points
    Oct 22, 2009 @ 09:27
    Wade
    0

    imageGen macro not displaying image - Only displaying Hello world

    Hi all,

    I've made an xslt macro to simply display an image using imageGen, however the image won't display correctly.  It only shows the default "Hello World" text that means it can't find the image.  I have made sure that imageGen is properly installed as I am using imageGen for other macros and they are all working fine.  I'm just stuck as to why this one isn't working.  

    This is the xslt code, with a macro called homepageimage

    <?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:template match="/">
    
    <div class="contentbluehomepic">
    
    <xsl:variable name="HomeImage" select="./data [@alias = 'mainImage']"/>
    
            <img><xsl:attribute name="src">/umbraco/ImageGen.aspx?image=<xsl:value-of select="$HomeImage"/></xsl:attribute>
                </img>
    
    
    </div>
    
    
    </xsl:template>
    
    </xsl:stylesheet>

    In the template I have added the following:

    <umbraco:Macro Alias="homepageimage" runat="server"></umbraco:Macro>

    Any help would be appreciated.

     

    Wade.

     

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Oct 22, 2009 @ 09:51
    Rasmus Berntsen
    1

    Well... I don't know if it makes a difference, but I would try using


    <xsl:variable name="HomeImage" select="$currentPage/data [@alias = 'mainImage']" />

     

    Does it work without ImageGen?

    And remember to add an alt-text if you want it to be valid xhtml... :)

  • keeler 3 posts 23 karma points
    Oct 22, 2009 @ 10:29
    keeler
    0

    Maybe try directly using the imageGen in the src attribute...

    The value of the first part after the ?image= should be: /media/nodenumber/fileName-and-extension

    You may want to make sure this is the case.. (using a copy-of perhaps?)

    mediaUrlTEST:<xsl:copy-of select="./data [@alias = 'mainImage']" />

     

    I used the {} as a substitute for value-of..

    <img src="/umbraco/ImageGen.ashx?image={$image/node/data[@alias='umbracoFile']}&amp;width={$width}&amp;height={$height}"
             id="{$id}"
             alt="{$alt}"
             title="{$title}"
             class="{$class}"           
        />

    Hope this helps!

  • dandrayne 1138 posts 2262 karma points
    Oct 22, 2009 @ 10:31
    dandrayne
    0

    You need to send imageGen an image path, where it looks like you might be sending it an ID.  If you're using a mediaPicker to get the image, this may work

    <img alt="">
    <xsl:attribute name="src">
    <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='mainImage'], 'false')/data [@alias = 'umbracoFile']" />
    <xsl:text>&amp;width=280&amp;compression=100</xsl:text>
    </xsl:attribute>
    </img>

    Note the getMedia, grabbing the image from the ID.

    It may be different if you're using an upload field, in which case simply do

     

    <xsl:copy-of select="$currentPage/data [@alias='mainImage']"/>

    To see the xml and adjust the above statement to pass getMedia the ID

    Dan

  • keeler 3 posts 23 karma points
    Oct 22, 2009 @ 10:34
    keeler
    0

    Maybe try directly using the imageGen in the src attribute...

    The value of the first part after the ?image= should be: /media/nodenumber/fileName-and-extension

    You may want to make sure this is the case.. (using a copy-of perhaps?)

    mediaUrlTEST:<xsl:copy-of select="./data [@alias = 'mainImage']" />

     

    I used the {} as a substitute for value-of..

    <img src="/umbraco/ImageGen.ashx?image={*** valid media url here ***}&amp;width={$width}&amp;height={$height}"
             id="{$id}"
             alt="{$alt}"
             title="{$title}"
             class="{$class}"           
        />

    Hope this helps!

    *** I used my own code snippet for the example before!

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Oct 22, 2009 @ 11:07
    Rasmus Berntsen
    0

    Ahhh... Of course, if you're trying to display an image from the media folder, then you'll have to go with one of the solutions above (from Keeler or Dan). Your solution does only work with the upload field. :)

  • katz 5 posts 25 karma points
    Oct 25, 2009 @ 11:08
    katz
    0

    Hi,

    I'm use ImageGen.dll in my website(not umbraco).

    When i write

    http://localhost/MySite/ImageGen.ashx?image=http://localhost/Perfumes/Photos/90/05595_311.jpg&width=100

    i get this error:
    File not found: http://localhost/Perfumes/Photos/90/05595_311.jpg

    But if i copy that url from the error, and paste it into the browser url, it opens the image fine. strange.

    Why it is happen?

  • Wade 43 posts 159 karma points
    Oct 26, 2009 @ 03:37
    Wade
    0

    Hi all thank you very much for your advice.  

    Berntsen's solution worked! Thanks.  For some reason the xslt didn't like the fact that I had only put 

    select="./data

     

    Instead of the folowing:

     select="$currentPage/data

  • MayMay 7 posts 26 karma points
    Nov 12, 2009 @ 16:18
    MayMay
    0

    Does any one know why my imagegen macro doesn't display image gallery only display the links of each image.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 12, 2009 @ 18:31
    Douglas Robar
    0

    @MayMay - you need to be more specific about the issue, and it would probably be appropriate to start a new forum post about it rather than continuing this thread that already has a solution for the original poster.

    cheers,
    doug.

  • MayMay 7 posts 26 karma points
    Nov 12, 2009 @ 22:16
    MayMay
    0

    Thanks Doug! I figured it out. The path to css is not right.

    MayMay

Please Sign in or register to post replies

Write your reply to:

Draft