In v4.5 the last statement you tried should work(with an uppercase F in umbracoFile), but the XML has been changed a bit from 4.5 to 4.5.1 so in 4.5.1 you can probably get the path to the image like this:
I use this method every time I'm in doubt about the XML I work with in the current context. Another example is to make sure a given property is represented on the current page. Then you'll just write out the $currentPage variable like this:
mainImage is just the alias I used where yours are called newsImage. Does that make more sense now?
In the beginning it can be a little difficult to just guess, and therefore it's always a good idea to see the XML instead of just shooting in the dark.
Yes, that helps. Thanks. And thanks for the links.
When I used the visualizer tool in the xsl editor, and decoded the result, it showed the nodes in all lower case (as shown in my first post on this topic), but when I put it in a <textarea> it showed the nodes in mixed case. Also, using the <textarea> caused an xslt error for some reason, but it seemed OK to ignore the error.
By the way, how did you get your <textarea> output so nicely formated? When I tried it, it was all on one line with no syntax highlighting.
Everytime I use this method, I'll grab all of the content from the textarea, and paste it into Visual Studio in a dummy.xml-file. Then Visual Studio formats the XML nicely which of course makes it a lot more readable. If you just get a single line of code inside of Visual Studio as well, try pressing Ctrl+k+d (or go to Edit-->Format Document).
If you don't have Visual Studio installed, you can just use your favorite editor like Notepad++, Dreamweaver etc.
Sun, isn't it to much work to go to into the database just to see the XML? Are you using it to see the current page or are you only using this method when you want to see all the XML found in the whole tree?
Need xslt help getting the path of an image file
I'm using Umbraco 4.5.1. I'm trying to display an image as explained on Umbraco.tv in the Using Content and Media Pickers video.
When I visualize this xslt statement:
<xsl:copy-of select="umbraco.library:GetMedia($currentPage/newsImage, 'false')" />
I get this: /media/168/hydrangeas.jpg1024768595284jpg
And when I decode it it I get this:
Now how do I get the path of the image?
As suggested in the video, I tried this:
<xsl:value-of select="umbraco.library:GetMedia($currentPage/newsImage, 'false')/data [@alias = 'umbracofile']" />
And the code in the Business Website Starter Package suggests this:
<xsl:value-of select="umbraco.library:GetMedia($currentPage/newsImage, 'false')/Image/umbracofile" />
But they yield a message saying the xslt didn't generate any output.
Help!
Hi there Steve
In v4.5 the last statement you tried should work(with an uppercase F in umbracoFile), but the XML has been changed a bit from 4.5 to 4.5.1 so in 4.5.1 you can probably get the path to the image like this:
<xsl:value-of select="umbraco.library:GetMedia($currentPage/newsImage, 'false')/umbracoFile" />
The only thing that has changed is the <Image>-tag in the XML. Hope the above snippet works for you :)
/Kim A
Kim,
Thanks for the prompt response! Yes, the snippet you provided works.
Question: where can I find this kind of information?
--steve
An approach I often use is to find out how my XML looks like. This is a good starting point.
In your case you could try printing out the XML returned by the GetMedia-extension. Like this:
I use this method every time I'm in doubt about the XML I work with in the current context. Another example is to make sure a given property is represented on the current page. Then you'll just write out the $currentPage variable like this:
/Kim A
Kim,
Thanks for the helpful suggestions.
However, I'm still kind of in the dark. The XML that the GetMedia extension returns contains this:
<umbracofile>/media/168/hydrangeas.jpg</umbracofile>
But I need to use /umbracoFile with an uppercase 'F' in my xslt. Where is this documented?
As a beginner, I feel like I'm spending a lot of time just guessing.
But I do appreciate the enthusiasm and helpfulness of the user community, so thanks!
Hi again Steve.
Try printing GetMedia out without the umbracoFile at the end.
I just tried this on a fresh install of umbraco 4.5.1 and i got the following XML returnerd:
As you can see this is the XML returned by the GetMedia extension. In here you have the umbracoFile, umbracoWidth etc. I printed it out like this:
mainImage is just the alias I used where yours are called newsImage. Does that make more sense now?
In the beginning it can be a little difficult to just guess, and therefore it's always a good idea to see the XML instead of just shooting in the dark.
By the way there's written a couple of Wiki entries about the new XML schema. Eg.: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema and http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema
I hope this explanation made a bit more sense to you Steve :)
/Kim A
Hi Kim,
Yes, that helps. Thanks. And thanks for the links.
When I used the visualizer tool in the xsl editor, and decoded the result, it showed the nodes in all lower case (as shown in my first post on this topic), but when I put it in a <textarea> it showed the nodes in mixed case. Also, using the <textarea> caused an xslt error for some reason, but it seemed OK to ignore the error.
By the way, how did you get your <textarea> output so nicely formated? When I tried it, it was all on one line with no syntax highlighting.
Thanks again!
--steve
Everytime I use this method, I'll grab all of the content from the textarea, and paste it into Visual Studio in a dummy.xml-file. Then Visual Studio formats the XML nicely which of course makes it a lot more readable. If you just get a single line of code inside of Visual Studio as well, try pressing Ctrl+k+d (or go to Edit-->Format Document).
If you don't have Visual Studio installed, you can just use your favorite editor like Notepad++, Dreamweaver etc.
/Kim A
I always see the database of umbraco to find out xml structure.
Sun, isn't it to much work to go to into the database just to see the XML? Are you using it to see the current page or are you only using this method when you want to see all the XML found in the whole tree?
/Kim A
is working on a reply...