Created
November 4, 2012 09:15
-
-
Save vgrem/4011023 to your computer and use it in GitHub Desktop.
XSLT style sheet for rendering EmbeddedVideoOnForm field
This file contains 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
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"> | |
<xsl:template match ="FieldRef[@Name='EmbeddedVideoOnForm']" mode="Computed_body" > | |
<xsl:param name="thisNode" select="."/> | |
<xsl:variable name="width"> | |
<xsl:call-template name="ensureVideoPlayerSize"> | |
<xsl:with-param name="videoSize" select="$thisNode/@VideoWidth"/> | |
<xsl:with-param name="defaultSize" select="560"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="height"> | |
<xsl:call-template name="ensureVideoPlayerSize"> | |
<xsl:with-param name="videoSize" select="$thisNode/@VideoHeight"/> | |
<xsl:with-param name="defaultSize" select="315"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="frameborder"> | |
<xsl:value-of select="$thisNode/@FrameBorder"/> | |
</xsl:variable> | |
<xsl:variable name="src"> | |
<xsl:value-of select="$thisNode/@URL"/> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="$thisNode/@EmbeddingMode ='IFrame'"> | |
<iframe width="{$width}" height="{$height}" src="{$src}" frameborder="{$frameborder}" allowfullscreen=""></iframe> | |
</xsl:when> | |
<xsl:otherwise> | |
<div>Not supported yet</div> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="ensureVideoPlayerSize"> | |
<xsl:param name="videoSize"/> | |
<xsl:param name="defaultSize"/> | |
<xsl:choose> | |
<xsl:when test="$videoSize > 0"> | |
<xsl:value-of select="$videoSize"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$defaultSize"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment