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"}}

Since version 0.68, it is also possible to embed a Hubnut with this action. Instead of using the id, use the data parameter to do this. It needs the full URL that Vimeo gives you when creating the Hubnut.
To illustrate, the URL that you will use as data needs to be taken from code that looks like this:
And you need to call it like this:
{{vimeo data="http://vimeo.com/hubnut/?user_id=thisisyou&color=00adef&background=ffffff&fullscreen=1&slideshow=0&stream=album&id=someinteger&server=vimeo.com" width="800" height="600"}}

The Hubnut feature was written in a hurry, so I cannot make any statement about its safety. Please think for yourself before using it. (or make a statement about its safety right here)

Save the following file as vimeo.php under the plugins/actions folder:

<?php
/**
 * Load a video from Vimeo into an iframe.
 *
 * @title       Vimeo in WikkaWiki
 * @package     Actions
 * @version     0.68
 * @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   string  $data   full URL of a Hubnut
 * @input   int     $height optional: height of the video
 * @input   int     $width  optional: width of the video
 * @output  string  iframe or object element
 */


// defaults
$id = '';
$data = '';
$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 == 'data') {$data = $vars['data'];}
       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 or Hubnut URL!</ins> ' . "\n"; }

// building output
if ( $data != '' ){
    $output = '<object type="application/x-shockwave-flash" width="%width" height="%height" data="%data"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="scale" value="showAll" /><param name="movie" value="%data" /></object>';
    $output = str_replace("%width", $width, $output);
    $output = str_replace("%height", $height, $output);
    $output = str_replace("%data", $data, $output);
} elseif ( $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
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki