I just upgraded our umbraco installation from 4.0.2.1 to 4.5 and I have chosen to use legacy XSLT so I don't have to re-create all of my current files.
The site is working fine except for a page that loops through images in a Media subfolder and displays them in an unordered list.
In my Media folder (id=1061) I have 2 images. Here is some code I am using to troubleshoot:
All that gets returned is "1". The same code in the last version returned "12".
Is there something wrong with my installation or database? This problem makes absolutely no sense to me at all since I have set the config to use legacy schema and nothing else has changed.
try resaving your image, I think there are a few changes to the way media is structured in 4.5. I did a 4.5 upgrade recently as well and had to resave all my images again before they would work properly. I wish there was a right-click republish all media nodes to do this.
@Matthew: I'd say you try that because the results you get from XSLT does not match the XML you posted - so somethin' fishy is very likely to be going on.
@Thomas - I found that trick here and tried it but this issue was still happening. For some reason it's working now with the extra /node. Any ideas why this could be the case, since according to everything I've looked at this shouldn't be the case.
D'oh - silly me! I was looking at the XML and assuming the top level node (id: 2633) was your $mediaId - but seeing now, that your original folder has another id (1061) it makes sense; you've got an extra folder in there now... are you saying that the upgrade created that "wrapping" folder, or how did that get there?
The wrapping folder existed in the last version too, but for some reason GetMedia is handling it differently. To show you, here is code I am using on both the old (4.0.2.1) and new (4.5) version:
Ok, I give up - there's something weird going on there.
The first screenshot (old version) shows what you'd get from using //node (i.e., descendant::node) to be concise, instead of /node (child::node) - the "correct" version (in terms of the XML/XSLT I've seen) is the second screenshot (new version) but I can't figure out why the old version did that. Initial thought was that a glitch in the matrix had the GetMedia() function return all nodes, whether from a subfolder or a sub-sub folder, at the same level, but I've just tried to verify that on a 4.0 site, which doesn't do that...
Have you tried comparing the old XML with the new - they can't possibly be the same... are they?
Looks identical to me. Weird. However, if you say the new code is working as you expect then I guess that's a good thing and that from now on GetMedia should work as it's supposed to. Is that right?
Strange, I had the same problem, only not with updating an umbraco installation. I just made a new website with a new umbraco installation. This was my xml output
I had to write: umbraco.library:GetMedia($JcarouselPage/fotoMap,
1)/Folder/Image for it to work
GetMedia for folder contents not separating Nodes
I just upgraded our umbraco installation from 4.0.2.1 to 4.5 and I have chosen to use legacy XSLT so I don't have to re-create all of my current files.
The site is working fine except for a page that loops through images in a Media subfolder and displays them in an unordered list.
In my Media folder (id=1061) I have 2 images. Here is some code I am using to troubleshoot:
<xsl:value-of select="umbraco.library:GetMedia($mediaId, 1)/node" />
This returns:
/media/60378/the_dark_side_of_the_moon_link_by_nes__still_the_best.png1920120099338png/media/60383/grooves.jpg63449684585jpg
As you can see I have 2 images there. However, before the upgrade this same code returned this:
/media/60378/the_dark_side_of_the_moon_link_by_nes__still_the_best.png1920120099338png
It seems like the nodes are not separated anymore. If I do a for-each like this:
<xsl:for-each select="umbraco.library:GetMedia($mediaId, 1)/node">
<xsl:value-of select="position()"/>
</xsl:for-each>
All that gets returned is "1". The same code in the last version returned "12".
Is there something wrong with my installation or database? This problem makes absolutely no sense to me at all since I have set the config to use legacy schema and nothing else has changed.
Please help!
Hi Matthew,
First thing we need to do is to have a look at the actual XML returned from GetMedia() - so do the following:
/Chriztian
try resaving your image, I think there are a few changes to the way media is structured in 4.5. I did a 4.5 upgrade recently as well and had to resave all my images again before they would work properly. I wish there was a right-click republish all media nodes to do this.
Chriztian, here is what shows up:
<node id="2633" version="01925325-4d6b-4326-878b-4cb91a0fe416" parentID="1060" level="2" writerID="9" nodeType="1031" template="0" sortOrder="3" createDate="2010-07-13T11:29:25" updateDate="2010-07-13T11:29:25" nodeName="Test" urlName="test" writerName="Matthew Urbano" nodeTypeAlias="Folder" path="-1,1060,2633"><data alias="contents" />
<node id="2634" version="9f09e433-2805-46e6-ae10-b39c29f0f631" parentID="2633" level="3" writerID="9" nodeType="1032" template="0" sortOrder="1" createDate="2010-07-13T11:29:33" updateDate="2010-07-13T11:29:33" nodeName="1" urlName="1" writerName="Matthew Urbano" nodeTypeAlias="Image" path="-1,1060,2633,2634"><data alias="umbracoFile">/media/60378/the_dark_side_of_the_moon_link_by_nes__still_the_best.png</data><data alias="umbracoWidth">1920</data><data alias="umbracoHeight">1200</data><data alias="umbracoBytes">99338</data><data alias="umbracoExtension">png</data></node>
<node id="2635" version="8fdb36d4-bb10-48b9-8afc-8623048bc3f2" parentID="2633" level="3" writerID="9" nodeType="1032" template="0" sortOrder="2" createDate="2010-07-13T11:29:40" updateDate="2010-07-13T11:29:40" nodeName="2" urlName="2" writerName="Matthew Urbano" nodeTypeAlias="Image" path="-1,1060,2633,2635"><data alias="umbracoFile">/media/60383/grooves.jpg</data><data alias="umbracoWidth">634</data><data alias="umbracoHeight">496</data><data alias="umbracoBytes">84585</data><data alias="umbracoExtension">jpg</data></node></node>
For recreating the xml for the medias just use /umbraco/dialogs/republish.aspx?xml=true which recreates the complete xml including the media xml.
Just try to recreate the complete xml.
hth, Thomas
@Thomas - evil trick :-)
@Matthew: I'd say you try that because the results you get from XSLT does not match the XML you posted - so somethin' fishy is very likely to be going on.
/Chriztian
I was able to get this to work thanks to Chriztian's suggestion and actually seeing the XML. Now, this works as expected:
<xsl:for-each select="umbraco.library:GetMedia($mediaId, 1)/node/node">
<xsl:value-of select="position()"/>
</xsl:for-each>
Adding the extra node allows me to get into the images within the folder. What I'm curious about is why did this change from the last version?
The ID of my media folder is the same as it was before. So now "umbraco.library:GetMedia($mediaId, 1)/node" doesn't work the same as it used to??
@Thomas - I found that trick here and tried it but this issue was still happening. For some reason it's working now with the extra /node. Any ideas why this could be the case, since according to everything I've looked at this shouldn't be the case.
@Chriztian: not evil, but hidden feature: http://our.umbraco.org/wiki/reference/xslt/mixed-schemas-after-upgrade *g*
D'oh - silly me! I was looking at the XML and assuming the top level node (id: 2633) was your $mediaId - but seeing now, that your original folder has another id (1061) it makes sense; you've got an extra folder in there now... are you saying that the upgrade created that "wrapping" folder, or how did that get there?
/Chriztian
The wrapping folder existed in the last version too, but for some reason GetMedia is handling it differently. To show you, here is code I am using on both the old (4.0.2.1) and new (4.5) version:
<xsl:template match="/">
<textarea rows="8" cols="40">
<xsl:copy-of select="umbraco.library:GetMedia(1061, 1)" />
</textarea>
<xsl:for-each select="umbraco.library:GetMedia(1061, 1)/node">
<xsl:value-of select="position()"/>
</xsl:for-each>
The old version shows this:
But the new version shows this:
Is this a bug or could my installation be messed up?
Ok, I give up - there's something weird going on there.
The first screenshot (old version) shows what you'd get from using //node (i.e., descendant::node) to be concise, instead of /node (child::node) - the "correct" version (in terms of the XML/XSLT I've seen) is the second screenshot (new version) but I can't figure out why the old version did that. Initial thought was that a glitch in the matrix had the GetMedia() function return all nodes, whether from a subfolder or a sub-sub folder, at the same level, but I've just tried to verify that on a 4.0 site, which doesn't do that...
Have you tried comparing the old XML with the new - they can't possibly be the same... are they?
/Chriztian
Ok, I created a new folder under Media for each version and put 2 images in each. Then i created a new XSLT file with this code:
<textarea rows="8" cols="40">
<xsl:copy-of select="umbraco.library:GetMedia(2635, 1)" />
</textarea>
Where 2635 (and 2638 for the new version) is the ID of the new Folder under Media. Here are the results.
Old version:
<node id="2635" version="3cc39d98-0cc0-4be1-b0ac-869a0118d03e" parentID="1060" level="2" writerID="9" nodeType="1031" template="0" sortOrder="3" createDate="2010-07-13T22:34:15" updateDate="2010-07-13T22:34:15" nodeName="Test" urlName="test" writerName="Matthew Urbano" nodeTypeAlias="Folder" path="-1,1060,2635"><data alias="contents" />
<node id="2636" version="979f460c-5205-40f8-9c99-33be342682f6" parentID="2635" level="3" writerID="9" nodeType="1032" template="0" sortOrder="1" createDate="2010-07-13T22:34:26" updateDate="2010-07-13T22:34:26" nodeName="1" urlName="1" writerName="Matthew Urbano" nodeTypeAlias="Image" path="-1,1060,2635,2636"><data alias="umbracoFile">/media/57741/grooves.jpg</data><data alias="umbracoWidth">634</data><data alias="umbracoHeight">496</data><data alias="umbracoBytes">84585</data><data alias="umbracoExtension">jpg</data></node>
<node id="2637" version="0451834d-96ce-47f2-8976-4cfce5946083" parentID="2635" level="3" writerID="9" nodeType="1032" template="0" sortOrder="2" createDate="2010-07-13T22:34:51" updateDate="2010-07-13T22:34:51" nodeName="2" urlName="2" writerName="Matthew Urbano" nodeTypeAlias="Image" path="-1,1060,2635,2637"><data alias="umbracoFile">/media/57746/record_groove.jpg</data><data alias="umbracoWidth">614</data><data alias="umbracoHeight">440</data><data alias="umbracoBytes">205015</data><data alias="umbracoExtension">jpg</data></node>
</node>
New version:
<node id="2638" version="aa0c5dae-947d-4564-88e5-4ed7427a8413" parentID="1060" level="2" writerID="9" nodeType="1031" template="0" sortOrder="3" createDate="2010-07-13T15:33:46" updateDate="2010-07-13T15:33:46" nodeName="Test" urlName="test" writerName="Matthew Urbano" nodeTypeAlias="Folder" path="-1,1060,2638"><data alias="contents" />
<node id="2639" version="4a303e86-ded0-4c1e-ac2b-996ba6bd0436" parentID="2638" level="3" writerID="9" nodeType="1032" template="0" sortOrder="1" createDate="2010-07-13T15:35:12" updateDate="2010-07-13T15:35:12" nodeName="1" urlName="1" writerName="Matthew Urbano" nodeTypeAlias="Image" path="-1,1060,2638,2639"><data alias="umbracoFile">/media/60403/grooves.jpg</data><data alias="umbracoWidth">634</data><data alias="umbracoHeight">496</data><data alias="umbracoBytes">84585</data><data alias="umbracoExtension">jpg</data></node>
<node id="2640" version="52c090c8-3aa3-4ef8-a7af-d4f68d26616c" parentID="2638" level="3" writerID="9" nodeType="1032" template="0" sortOrder="2" createDate="2010-07-13T15:35:20" updateDate="2010-07-13T15:35:20" nodeName="2" urlName="2" writerName="Matthew Urbano" nodeTypeAlias="Image" path="-1,1060,2638,2640"><data alias="umbracoFile">/media/60408/record_groove.jpg</data><data alias="umbracoWidth">614</data><data alias="umbracoHeight">440</data><data alias="umbracoBytes">205015</data><data alias="umbracoExtension">jpg</data></node>
</node>
Looks identical to me. Weird. However, if you say the new code is working as you expect then I guess that's a good thing and that from now on GetMedia should work as it's supposed to. Is that right?
Strange,
I had the same problem, only not with updating an umbraco installation. I just made a new website with a new umbraco installation. This was my xml output
I had to write: umbraco.library:GetMedia($JcarouselPage/fotoMap, 1)/Folder/Image for it to work
<Folder id="1067" version="a76b0e1d-cb51-4c96-aeaa-15f7f06b5321" parentID="-1" level="1" writerID="0" nodeType="1031" template="0" sortOrder="49" createDate="2010-07-15T16:32:05" updateDate="2010-07-15T16:32:05" nodeName="Jcarousel" urlName="jcarousel" writerName="Administrator" nodeTypeAlias="Folder" path="-1,1067"><contents />
<Image id="1070" version="e81fe50c-1f8b-4ccd-bbe0-646aa5c140dd" parentID="1067" level="2" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-07-15T16:36:28" updateDate="2010-07-15T16:36:28" nodeName="Foto 1" urlName="foto1" writerName="Administrator" nodeTypeAlias="Image" path="-1,1067,1070"><umbracoFile>/media/254/4.jpg</umbracoFile><umbracoWidth>350</umbracoWidth><umbracoHeight>200</umbracoHeight><umbracoBytes>8827</umbracoBytes><umbracoExtension>jpg</umbracoExtension><fotoCrop><crops date="15/07/2010 17:04:36"><crop name="Foto Crop" x="40" y="0" x2="310" y2="200" url="/media/254/4_Foto Crop.jpg" /></crops></fotoCrop></Image>
<Image id="1072" version="e4af029d-ad24-494a-9279-3ec9e7227b8a" parentID="1067" level="2" writerID="0" nodeType="1032" template="0" sortOrder="2" createDate="2010-07-15T17:05:53" updateDate="2010-07-15T17:05:53" nodeName="Foto 2" urlName="foto2" writerName="Administrator" nodeTypeAlias="Image" path="-1,1067,1072"><umbracoFile>/media/271/2.jpg</umbracoFile><umbracoWidth>350</umbracoWidth><umbracoHeight>200</umbracoHeight><umbracoBytes>8116</umbracoBytes><umbracoExtension>jpg</umbracoExtension><fotoCrop><crops date="15/07/2010 17:06:01"><crop name="Foto Crop" x="34" y="0" x2="317" y2="200" url="/media/271/2_Foto Crop.jpg" /></crops></fotoCrop></Image></Folder>
Just to let everyone know - this is a bug that's been fixed for Umbraco 4.5.1
/Chriztian
is working on a reply...