Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Burnett 213 posts 262 karma points
    Feb 14, 2013 @ 17:01
    William Burnett
    0

    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)

    <xsl:variable name="mediaFolder" select="umbraco.library:GetMedia(1159, true())" />
      
      <ul> 
       <xsl:for-each select="$mediaFolder/Image">

         <xsl:variable name="picFile" select="umbracoFile"/>
                <img>             
        <xsl:attribute name="src">
         <xsl:text>/ImageGen.ashx?image=</xsl:text>
         <xsl:value-of select="$picFile"/>
         <xsl:text>&amp;width=150&amp;height=98%&amp;constrain=true</xsl:text>
        </xsl:attribute>
        </img>
      
       </xsl:for-each>
      </ul> 
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 14, 2013 @ 21:05
    Jan Skovgaard
    0

    Hi William

    Do you get all the images if you change this line in your for-each? $mediaFolder//Image

    /Jan

  • William Burnett 213 posts 262 karma points
    Feb 14, 2013 @ 21:45
    William Burnett
    0

    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.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Feb 14, 2013 @ 21:55
    Chriztian Steinmeier
    101

    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:

    1. They're actually using another Media Type (e.g. BannerImage or Image2 etc.)
    2. There's something wrong with the Media XML so it needs republishing
    #1 is easy to test - instead of $mediaFolder/Image, use $mediaFolder/*[@nodeTypeAlias] - and see if you get inside the loop.
    #2 I'm not sure about, but you could try going to /umbraco/dialogs/republish.aspx?xml=true in your browser to have the XML regenerated - worth a shot.

     

    /Chriztian 

  • William Burnett 213 posts 262 karma points
    Feb 14, 2013 @ 22:27
    William Burnett
    0

    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?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 14, 2013 @ 23:16
    Jan Skovgaard
    0

    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

  • William Burnett 213 posts 262 karma points
    Feb 15, 2013 @ 00:09
    William Burnett
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft