Copied to clipboard

Flag this post as spam?

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


  • Eran Meir 401 posts 543 karma points
    Aug 21, 2010 @ 15:32
    Eran Meir
    0

    Media Picker, folder or a file?

    hi, how can i be sure if the media that selected from media picker is a file or folder?

    i searched for a solution in the forum but didn't find it.

    using Umbraco 4.5.1

    thank you.

  • Hendrik Jan 71 posts 137 karma points
    Aug 21, 2010 @ 16:43
    Hendrik Jan
    0

    Hey Eran,

     

    you should be able to check the type like this:

      <xsl:variable name="image" select="umbraco.library:GetMedia(...., false())"/>

      <xsl:value-of select="name($image)"/>


    Putting it in an choose statement:    (depending on the alias of you media type ofcourse!)

      <xsl:choose>
        <xsl:when test="name($image) = 'image'">
           it's an image
        </xsl:when>
        <xsl:otherwise>
           it's not an image
        </xsl:otherwise>
      </xsl:choose>

     

     

    Regards,

     

    Niels

  • Kim Andersen 1447 posts 2196 karma points MVP
    Aug 21, 2010 @ 16:46
    Kim Andersen
    0

    Hi there Eran

    Let's say you have a media picker with an alias of "myMediaPicker". Consider the following XSLT:

    <xsl:if test="umbraco.library:GetMedia($currentPage/myMediaPicker, 'false')[name()='Folder']">The selected node is a Folder</xsl:if> 
    <xsl:if test="umbraco.library:GetMedia($currentPage/myMediaPicker, 'false')[name()='File']">The selected node is a File</xsl:if>
    <xsl:if test="umbraco.library:GetMedia($currentPage/myMediaPicker, 'false')[name()='Image']">The selected node is an Image</xsl:if>

    The above code will write out which type of media item you have choosen in the medie picker. Of course you can put the code into a <xsl:choose> instead of several <xsl:if>'s if that fits your needs.

    I hope the code makes sense :)

    /Kim A

  • Eran Meir 401 posts 543 karma points
    Aug 22, 2010 @ 13:20
    Eran Meir
    0

    thank you very much !

    i will try it

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies