Skip to content

Instantly share code, notes, and snippets.

@xpathr
Created May 10, 2012 14:42
Show Gist options
  • Save xpathr/2653584 to your computer and use it in GitHub Desktop.
Save xpathr/2653584 to your computer and use it in GitHub Desktop.
Vimeo Embed by rainerborene
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Name: Vimeo Embed
Version: 1.0
Author: Rainer Borene <rainerborene@gmail.com>
URL: http://www.symphony-cms.com/download/xslt-utilities/view/34817/
Parameters:
* vimeo-element (required) XPath to the vimeo element
* color (optional) Color
* show_title (optional) Show title
* show_byline (optional) Show byline
* show_text (optional) Show text link below video
* show_description (optional) Show video description below video
* show_portrait (optional) Show portrait
-->
<xsl:template name="vimeo">
<xsl:param name="vimeo-element"/>
<xsl:param name="color"/>
<xsl:param name="show_title"/>
<xsl:param name="show_byline"/>
<xsl:param name="show_text"/>
<xsl:param name="show_description"/>
<xsl:param name="show_portrait"/>
<xsl:if test="$vimeo-element/@clip-id and $vimeo-element/@duration and $vimeo-element/@plays">
<xsl:variable name="custom_color">
<xsl:text>&amp;color=</xsl:text>
<xsl:choose>
<xsl:when test="$color"><xsl:value-of select="$color"/></xsl:when>
<xsl:otherwise>00adef</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="title">
<xsl:text>&amp;show_title=</xsl:text>
<xsl:choose>
<xsl:when test="$show_title">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="byline">
<xsl:text>&amp;show_byline=</xsl:text>
<xsl:choose>
<xsl:when test="$show_byline">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="text">
<xsl:if test="$show_text">
<p>
<a href="{concat('http://vimeo.com/', $vimeo-element/@clip-id)}">
<xsl:value-of select="$vimeo-element/title"/>
</a>
from
<a href="{$vimeo-element/user/url}">
<xsl:value-of select="$vimeo-element/name"/>
</a>
on
<a href="http://vimeo.com">Vimeo</a>.
</p>
</xsl:if>
</xsl:variable>
<xsl:variable name="description">
<xsl:if test="$show_description">
<p>
<xsl:value-of select="$vimeo-element/caption"/>
</p>
</xsl:if>
</xsl:variable>
<xsl:variable name="portrait">
<xsl:text>&amp;show_portrait=</xsl:text>
<xsl:choose>
<xsl:when test="$show_portrait">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="url">
<xsl:value-of select="concat('http://vimeo.com/moogaloop.swf?clip_id=', $vimeo-element/@clip-id)"/>
<xsl:value-of select="concat($title, $byline, $portrait, $custom_color, '&amp;server=vimeo.com&amp;fullscreen=1')"/>
</xsl:variable>
<object width="{$vimeo-element/@width}" height="{$vimeo-element/@height}">
<param name="allowfullscreen" value="true"/>
<param name="allowscriptaccess" value="always"/>
<param name="movie" value="{$url}"/>
<embed src="{$url}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{$vimeo-element/@width}" height="{$vimeo-element/@height}"></embed>
</object>
<xsl:copy-of select="$text"/>
<xsl:copy-of select="$description"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment