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.
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.
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
Hi there Eran
Let's say you have a media picker with an alias of "myMediaPicker". Consider the following XSLT:
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
thank you very much !
i will try it
is working on a reply...