GetMedia only returns contents from SOME media folders - please help!
6.0rc
Code below.
Trying to return contents of media folder to create gallery. Sample code below works, but ONLY on some media folders!
PLEASE examine the basic folder structure in my media section. Notice that any FOLDER with an "id" greater than 1500 works and the images are returned by the code below. ANY FOLDER with an "id" lower than "1500" does not return anything in the for/next loop. The LOOP is not entered, as even plain text nested in the loop is NOT displayed. In reality the "cutoff" id does not appear to actually be 1500, as I think a media folder with 1496 also works. But clearly "old" vs "newer" media is making a difference. The "newer" media folders in my tree return data via the XSLT, the older media folders do not. I looked in the DB and see nothing odd between the different media folder id rows.
Am I doing something wrong, or is this a huge bug?
Media ---Projects (id 1100) ----------Folder1 (id 1250) ----------------------NOT WORKING ----------------Image1 (id 1122) ----------------Image2 (id 1149 ----------------Image3 (id 1150) ----------Folder2 (id 1523) ----------------------WORKING ----------------Image1 (id 1152) ----------------Image2 (id 1179) ----------------Image3 (id 118) ----------Folder3 (id 1251) ----------------------NOT WORKING ----------------Image1 (id 1162) ----------------Image2 (id 1149) ----------------Image3 (id 1148) ---Other (d 1544) ----------Folder4 (id 1566) ----------------------WORKING ----------------Image1 (id 1567) ----------------Image2 (id 1224) ----------------Image3 (id 1137) ----------Folder5 (id 1593) ----------------------WORKING ----------------Image1 (id 1252) ----------------Image2 (id 1279) ----------------Image3 (id 1228) ----------Folder6 (id 1251) ----------------------NOT WORKING ----------------Image1 (id 1362) ----------------Image2 (id 1349) ----------------Image3 (id 1338)
Thank you for responding, but I am not sure I follow your question. Are you asking me to change something, or asking for clarification as to what I am changing to get results.
When getmedia points to a media folder with an id of 1500 or greater it works. When it points to a media folder with an id less than 1500 it fails, to the point that nothing inside the for loop is executed. So I suspect it returns 0 or null in the for-each check
Ohh and if I pass the ID of the parent, child folders are NOT returned! It ONLY works if the images directly IN the folder called by getmedia. For Example (from above) if I pass 1544, I do not get images from 1566 and 1593. The for-each fails there also.
I have checked the media types, and they are all the same.
Test #1 fails, I still do not get inside the loop
Test #2 helped a great deal. I can now at least see the images in the folders taht were not working. Any idea on why or what happened? Is this something that is going to be a recurring issue?
Yes I wanted you to add an extra forward slash to the expression in the for-each loop to see if that changed anything suspecting that you only got the images from the chosen folder and not the subfolders - sorry I was not very clear about that.
By adding the extra forward slash all Image elements should be hit (please note it's not recommened to do so, just wanted to make a test) - but I'm happy to see you got the issue solved with the help from Chriztian :)
Ahh... I see it now! You would think with a 24" monitor I would have noticed the extra slash.
It looks like my XML cache was bad for some reason and the republish worked.
Thanks for all the help folks, I spent days fiddling with this and it never occured to me to republish the entire site. I am still a bit afraid to do that, as in the past it has caused me some issues, but in this case it appeared to help.
GetMedia only returns contents from SOME media folders - please help!
6.0rc
Code below.
Trying to return contents of media folder to create gallery. Sample code below works, but ONLY on some media folders!
PLEASE examine the basic folder structure in my media section. Notice that any FOLDER with an "id" greater than 1500 works and the images are returned by the code below. ANY FOLDER with an "id" lower than "1500" does not return anything in the for/next loop. The LOOP is not entered, as even plain text nested in the loop is NOT displayed. In reality the "cutoff" id does not appear to actually be 1500, as I think a media folder with 1496 also works. But clearly "old" vs "newer" media is making a difference. The "newer" media folders in my tree return data via the XSLT, the older media folders do not. I looked in the DB and see nothing odd between the different media folder id rows.
Am I doing something wrong, or is this a huge bug?
Media
---Projects (id 1100)
----------Folder1 (id 1250) ----------------------NOT WORKING
----------------Image1 (id 1122)
----------------Image2 (id 1149
----------------Image3 (id 1150)
----------Folder2 (id 1523) ----------------------WORKING
----------------Image1 (id 1152)
----------------Image2 (id 1179)
----------------Image3 (id 118)
----------Folder3 (id 1251) ----------------------NOT WORKING
----------------Image1 (id 1162)
----------------Image2 (id 1149)
----------------Image3 (id 1148)
---Other (d 1544)
----------Folder4 (id 1566) ----------------------WORKING
----------------Image1 (id 1567)
----------------Image2 (id 1224)
----------------Image3 (id 1137)
----------Folder5 (id 1593) ----------------------WORKING
----------------Image1 (id 1252)
----------------Image2 (id 1279)
----------------Image3 (id 1228)
----------Folder6 (id 1251) ----------------------NOT WORKING
----------------Image1 (id 1362)
----------------Image2 (id 1349)
----------------Image3 (id 1338)
Hi William
Do you get all the images if you change this line in your for-each? $mediaFolder//Image
/Jan
Jan,
Thank you for responding, but I am not sure I follow your question. Are you asking me to change something, or asking for clarification as to what I am changing to get results.
When getmedia points to a media folder with an id of 1500 or greater it works. When it points to a media folder with an id less than 1500 it fails, to the point that nothing inside the for loop is executed. So I suspect it returns 0 or null in the for-each check
This works as expected:
name="mediaFolder"select="umbraco.library:GetMedia(1519, true())"/>
This does not return anything:
name="mediaFolder"select="umbraco.library:GetMedia(1108, true())"/>
Both are media folders with the same parent...
Ohh and if I pass the ID of the parent, child folders are NOT returned! It ONLY works if the images directly IN the folder called by getmedia. For Example (from above) if I pass 1544, I do not get images from 1566 and 1593. The for-each fails there also.
Hi William,
I assume that you're using those ids in the first line (the call to the GetMedia() extension).
If you're not even getting inside the loop as you say, there's simply no Image elements in those folders — which could be for two reasons:
/Chriztian
I have checked the media types, and they are all the same.
Test #1 fails, I still do not get inside the loop
Test #2 helped a great deal. I can now at least see the images in the folders taht were not working. Any idea on why or what happened? Is this something that is going to be a recurring issue?
Hi William
Yes I wanted you to add an extra forward slash to the expression in the for-each loop to see if that changed anything suspecting that you only got the images from the chosen folder and not the subfolders - sorry I was not very clear about that.
By adding the extra forward slash all Image elements should be hit (please note it's not recommened to do so, just wanted to make a test) - but I'm happy to see you got the issue solved with the help from Chriztian :)
/Jan
Ahh... I see it now! You would think with a 24" monitor I would have noticed the extra slash.
It looks like my XML cache was bad for some reason and the republish worked.
Thanks for all the help folks, I spent days fiddling with this and it never occured to me to republish the entire site. I am still a bit afraid to do that, as in the past it has caused me some issues, but in this case it appeared to help.
is working on a reply...