Created
February 23, 2011 11:14
-
-
Save leekelleher/840304 to your computer and use it in GitHub Desktop.
Generic XSLT template for Media items in Umbraco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE xsl:stylesheet [ | |
<!ENTITY nbsp " "> | |
]> | |
<xsl:stylesheet | |
version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxml="urn:schemas-microsoft-com:xslt" | |
xmlns:umbraco.library="urn:umbraco.library" | |
exclude-result-prefixes="msxml umbraco.library"> | |
<xsl:output method="xml" omit-xml-declaration="yes" /> | |
<!-- ERROR --> | |
<xsl:template match="error" mode="media" priority="1"> | |
<xsl:comment> | |
<xsl:value-of select="." /> | |
</xsl:comment> | |
</xsl:template> | |
<!-- IMAGE --> | |
<xsl:template match="Image" mode="media" priority="1"> | |
<xsl:if test="normalize-space(umbracoFile)"> | |
<img src="{umbracoFile}" height="{umbracoHeight}" width="{umbracoWidth}" alt="{(altText | @nodeName[not(normalize-space(../altText))])[1]}" /> | |
</xsl:if> | |
</xsl:template> | |
<!-- FOLDER --> | |
<xsl:template match="Folder" mode="media" priority="1"> | |
<xsl:if test="*[@nodeName]"> | |
<ul title="{@nodeName}"> | |
<xsl:for-each select="*[@nodeName]"> | |
<li> | |
<xsl:apply-templates select="." mode="media"> | |
<xsl:sort select="@sortOrder" order="ascending" data-type="number" /> | |
</xsl:apply-templates> | |
</li> | |
</xsl:for-each> | |
</ul> | |
</xsl:if> | |
</xsl:template> | |
<!-- FILE --> | |
<xsl:template match="File" mode="media" priority="1"> | |
<xsl:if test="normalize-space(umbracoFile)"> | |
<a href="{umbracoFile}"> | |
<xsl:value-of select="@nodeName" /> | |
<!-- possible to use "umbracoExtension" and "umbracoBytes" here --> | |
</a> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template match="*[@id]" mode="media" priority="0" /> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment