Revision [21343]
This is an old revision of VimeoAction made by BrianKoontz on 2011-02-17 21:47:57.
Loading a Vimeo video
This action inserts a Vimeo video into a page by loading it into an iframe. It was adapted from VideoAction by TormodHaugen, which embeds the video instead. That also works fine, but it does not match XHTML specification.
To use this action, copy or note the video id from the Vimeo url (currently a large integer). Use it as parameter when calling the action. Optional parameters are width and height which are set with arbitrary default values.
An example: {{vimeo id="13942000" width="800" height="600"}}
Save the following file as vimeo.php under plugins/actions folder:
<?php
/**
* Load a video from Vimeo into an iframe.
*
* @title Vimeo in WikkaWiki
* @package Actions
* @version 0.67
* @author Alex Olieman (http://olieman.net)
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @history Adapted from VideoAction by TormodHaugen
*
* @uses Wakka::htmlspecialchars_ent()
*
* @input string $id id of the video on vimeo
* @input int $height optional: height of the video
* @input int $width optional: width of the video
* @output string object element
*/
// defaults
$id = '';
$width = 440;
$height = 330;
$errors = '';
// params
if (is_array($vars))
{
foreach ($vars as $param => $value)
{
if ($param == 'id') {$id = $this->htmlspecialchars_ent($vars['id']);}
if ($param == 'width' && (int)$vars['width'] > 0) {$width = (int)$vars['width'];}
if ($param == 'height' && (int)$vars['height'] > 0) {$height = (int)$vars['height'];}
}
}
if($id == '') { $errors .= '<ins>You did not provide a correct id!</ins> ' . "\n"; }
// building output
if ( $id != '' ) {
$output = '<iframe src="http://player.vimeo.com/video/' . $id . '" width="' . $width . '" height="' . $height . '" frameborder="0">';
$output .= 'Sorry, to watch this video you need a browser that supports iframes.</iframe>' . "\n";
} else { $output = $errors; }
echo $output;
?>
/**
* Load a video from Vimeo into an iframe.
*
* @title Vimeo in WikkaWiki
* @package Actions
* @version 0.67
* @author Alex Olieman (http://olieman.net)
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @history Adapted from VideoAction by TormodHaugen
*
* @uses Wakka::htmlspecialchars_ent()
*
* @input string $id id of the video on vimeo
* @input int $height optional: height of the video
* @input int $width optional: width of the video
* @output string object element
*/
// defaults
$id = '';
$width = 440;
$height = 330;
$errors = '';
// params
if (is_array($vars))
{
foreach ($vars as $param => $value)
{
if ($param == 'id') {$id = $this->htmlspecialchars_ent($vars['id']);}
if ($param == 'width' && (int)$vars['width'] > 0) {$width = (int)$vars['width'];}
if ($param == 'height' && (int)$vars['height'] > 0) {$height = (int)$vars['height'];}
}
}
if($id == '') { $errors .= '<ins>You did not provide a correct id!</ins> ' . "\n"; }
// building output
if ( $id != '' ) {
$output = '<iframe src="http://player.vimeo.com/video/' . $id . '" width="' . $width . '" height="' . $height . '" frameborder="0">';
$output .= 'Sorry, to watch this video you need a browser that supports iframes.</iframe>' . "\n";
} else { $output = $errors; }
echo $output;
?>
CategoryUserContributions