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
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
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. :)
@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.
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 " "> ]> <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.
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... :)
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..
Hope this helps!
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
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
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..
Hope this helps!
*** I used my own code snippet for the example before!
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. :)
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?
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
Does any one know why my imagegen macro doesn't display image gallery only display the links of each image.
@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.
Thanks Doug! I figured it out. The path to css is not right.
MayMay
is working on a reply...