Ok, this might be an overly retarded question, but i just cant get imagegen to output a damp-classic image. it SHOULD be the same as just an ordinary image but i just cant get it working.
So, how do i do it? the alias for the property is "vp-thumb", if that helps, if more information is needed, please ask.
Also, i think a code snippet is uneeded as its pretty straightforward i guess, its just me that might have overlooked something.
("vp-SliderPicture" is the alias for another picture that is also damp classic, but it was the only code snippet i had of it in use and also i apologize for the poor formatting, posting doesnt work very well right now)
That above gives a int32 buffer overflow exception but i knew it was wrong to begin with i just kept experimenting until i hit something that worked, because i have no idea how it works to begin with...
We will need to step back and take this one step at a time.
1. Do you have an <img> tag that works with the vp-Thumb property at all? One that doesn't try to use ImageGen but only outputs the vp-Thumb itself.
Can you show us that line of XSLT? This is the first step; get the DAMP image to appear.
2. Once you have the above, please double-check that you have ImageGen installed properly. What output do you get when you visit /imagegen.ashx?version on your site?
3. Now that you have good XSLT for the DAMP image and you know ImageGen is functioning properly it is a fairly simple matter to use them together. First, add /imagegen.ashx?image= at the start of your src= tag. ImageGen won't resize the image but will return it at the original size just as if you hadn't included ImageGen. When that works, you can start adding parameters to the ImageGen command for width, height, etc.
Be sure that when you use the '&' character in XSLT that you always escape it to '&' because that's a requirement of XSLT. In otherwords, in an XSLT macro in order to get &width=425&height=250 you'd write &width=425&height=250.
No, i cant get it to output an image at all (yes its an img tag), i have a feeling that im using DAMP wrong. According to the DAMP sample xslt file, i can get the image like this:
But thats it. The document contains several damp classic properties, so i need to get one with a specific alias. I dont know how to tell it with that syntax to look for that specific file.
Im sorry that this might be out of your field, i initially thought it had something to do with imagegen but it looks like that isnt the case. Sorry that you are going out of your way to help me.
Also, ive been using imagegen with DAMP new with great success and that is working fine, and im very happy with imagegen in that regard as it saves us a lot of time creating several versions of the same picture.
Ok, finnaly got rid of that int32 bufferoverflow exception so i can now display the image without imagegen, yet. It was a very roundabout way so i will just post it here as an example, because apparently i had to put it in a loop before it wanted to cooperate. Which in my eyes isnt a correct solution.
Ah, I think I know the root cause of the problem - the umbraco.library:GetMedia() call when you save the XSLT macro gives the Int32 error. This is a common frustration and can lead people down the wrong path to find a solution.
Time for some background on how Umbraco works...
When you save an XSLT macro Umbraco will compile it and test it against the first page in your content tree (typically that'll be the homepage). This will help find errors in the XSLT before you save it and then get errors at runtime on your site.
The trouble is that sometimes the homepage is totally inappropriate to be the source page for the macro being saved and the macro would be just fine when run against the real content pages it is meant for. Worse, the umbraco.library:GetMedia() call will give that nasty Int32 error if the media item you're trying to get doesn't exist (rather than failing silently). Combine these two 'features' and you can get the behavior you described - you can't even save the xslt file without getting the Int32 error.
There are two ways around this. The easy way is to tick the 'skip testing' checkbox before you save the XSLT. This will save the file but will not test it against the first page in your site. You won't get the benefit of any error checking but then again the file will save and you can run it on your site in the proper context and it may work just fine in that situation. You just have to remember to tick that box every time you want to save the xslt file.
The second way is to put an <xsl:if> test around the code that has the GetMedia() call. Typically, whatever you have in your GetMedia() call is the same thing you'd put in the xsl:if. An example:
You'd put an xsl:if around it so that when the XSLT is saved it can still be tested but the test code won't process what's in the xsl:if block because when testing against the homepage it won't be valid (but it will be valid when run in its proper place in the website). Like this:
What you have in your elaborate example is a for-each loop with xsl:when conditions that serve the same purpose. But I bet you can simplify your macro dramatically now that you know this background info.
I greatly appreciate that you will explain it to me in such detail, it will help me definetly help me in the future as reference. Its hard to find proper explanations to problems such as this.
Im sorry that this ended up having nothing to do with imagegen, though i didnt anticipate that at first.
I really wanted to optimize my code with your example above but that doesnt work either. It compiles fine, but no picture is shown.
Sorry for bumping, i still cant get ImageGen to work with DAMP Classic, here is my current code:
(the document it displays has two image properties. One DAMP New and one DAMP Classic. If one is empty it displays the other, and it works fine. The problem is that the DAMP Classic image is pretty big, hence why i want to use imagegen with it. How do i implement it in the snippet below? Because whatever i try doesnt work.
Using imagegen with DAMP classic
Ok, this might be an overly retarded question, but i just cant get imagegen to output a damp-classic image. it SHOULD be the same as just an ordinary image but i just cant get it working.
So, how do i do it? the alias for the property is "vp-thumb", if that helps, if more information is needed, please ask.
Also, i think a code snippet is uneeded as its pretty straightforward i guess, its just me that might have overlooked something.
What does your HTML output?
Rich
I cant get HTML output, because it doesnt work, here is the code if you want, but its pretty useless...:
<img class="vpSliderImg" src="/ImageGen.ashx?image={umbraco.library:GetMedia(vp-SliderPicture/classic, 0)/umbracoFile}&width=425&height=250&constrain=false"/>
("vp-SliderPicture" is the alias for another picture that is also damp classic, but it was the only code snippet i had of it in use and also i apologize for the poor formatting, posting doesnt work very well right now)
That above gives a int32 buffer overflow exception but i knew it was wrong to begin with i just kept experimenting until i hit something that worked, because i have no idea how it works to begin with...
Hi, Frederik,
We will need to step back and take this one step at a time.
1. Do you have an <img> tag that works with the vp-Thumb property at all? One that doesn't try to use ImageGen but only outputs the vp-Thumb itself.
Can you show us that line of XSLT? This is the first step; get the DAMP image to appear.
2. Once you have the above, please double-check that you have ImageGen installed properly. What output do you get when you visit /imagegen.ashx?version on your site?
3. Now that you have good XSLT for the DAMP image and you know ImageGen is functioning properly it is a fairly simple matter to use them together. First, add /imagegen.ashx?image= at the start of your src= tag. ImageGen won't resize the image but will return it at the original size just as if you hadn't included ImageGen. When that works, you can start adding parameters to the ImageGen command for width, height, etc.
Be sure that when you use the '&' character in XSLT that you always escape it to '&' because that's a requirement of XSLT. In otherwords, in an XSLT macro in order to get &width=425&height=250 you'd write &width=425&height=250.
Let us know what you find out.
cheers,
doug.
Thank you for replying.
No, i cant get it to output an image at all (yes its an img tag), i have a feeling that im using DAMP wrong. According to the DAMP sample xslt file, i can get the image like this:
<img src="{umbraco.library:GetMedia($currentPage/classic, 0)/umbracoFile}" height="150px;" />
But thats it. The document contains several damp classic properties, so i need to get one with a specific alias. I dont know how to tell it with that syntax to look for that specific file.
Im sorry that this might be out of your field, i initially thought it had something to do with imagegen but it looks like that isnt the case. Sorry that you are going out of your way to help me.
Also, ive been using imagegen with DAMP new with great success and that is working fine, and im very happy with imagegen in that regard as it saves us a lot of time creating several versions of the same picture.
Ok, finnaly got rid of that int32 bufferoverflow exception so i can now display the image without imagegen, yet. It was a very roundabout way so i will just post it here as an example, because apparently i had to put it in a loop before it wanted to cooperate. Which in my eyes isnt a correct solution.
Ah, I think I know the root cause of the problem - the umbraco.library:GetMedia() call when you save the XSLT macro gives the Int32 error. This is a common frustration and can lead people down the wrong path to find a solution.
Time for some background on how Umbraco works...
When you save an XSLT macro Umbraco will compile it and test it against the first page in your content tree (typically that'll be the homepage). This will help find errors in the XSLT before you save it and then get errors at runtime on your site.
The trouble is that sometimes the homepage is totally inappropriate to be the source page for the macro being saved and the macro would be just fine when run against the real content pages it is meant for. Worse, the umbraco.library:GetMedia() call will give that nasty Int32 error if the media item you're trying to get doesn't exist (rather than failing silently). Combine these two 'features' and you can get the behavior you described - you can't even save the xslt file without getting the Int32 error.
There are two ways around this. The easy way is to tick the 'skip testing' checkbox before you save the XSLT. This will save the file but will not test it against the first page in your site. You won't get the benefit of any error checking but then again the file will save and you can run it on your site in the proper context and it may work just fine in that situation. You just have to remember to tick that box every time you want to save the xslt file.
The second way is to put an <xsl:if> test around the code that has the GetMedia() call. Typically, whatever you have in your GetMedia() call is the same thing you'd put in the xsl:if. An example:
Assume this gives an error:
You'd put an xsl:if around it so that when the XSLT is saved it can still be tested but the test code won't process what's in the xsl:if block because when testing against the homepage it won't be valid (but it will be valid when run in its proper place in the website). Like this:
doug.
I greatly appreciate that you will explain it to me in such detail, it will help me definetly help me in the future as reference. Its hard to find proper explanations to problems such as this.
Im sorry that this ended up having nothing to do with imagegen, though i didnt anticipate that at first.
I really wanted to optimize my code with your example above but that doesnt work either. It compiles fine, but no picture is shown.
<xsl:if test="string(vp-SliderPicture/classic) != '' ">
<img class="vpSliderImg" src="umbraco.library:GetMedia({vp-SliderPicture/classic}, 0)" width="425" height="250" />
</xsl:if>
Though its far from pretty, guess im stuck with using my ugly method for now.
Well, if you leave this thread i understand that, this belongs in another sub-forum now, but i just wanted to put this last bit out there.
Again, thank you for your time.
Sorry for bumping, i still cant get ImageGen to work with DAMP Classic, here is my current code:
(the document it displays has two image properties. One DAMP New and one DAMP Classic. If one is empty it displays the other, and it works fine. The problem is that the DAMP Classic image is pretty big, hence why i want to use imagegen with it. How do i implement it in the snippet below? Because whatever i try doesnt work.
is working on a reply...