=====Embedded Video=====
This is a first try at an action / plugin embedding a video.
For now, the action embeds youtube and vimeo videos as easy as: ""{{video url="http://www.youtube.com/watch?v=-dnL00TdmLY"}}""
Other parameters other than ''url'' are ''type'' and ''id'' (replaces url) and ''width'' and ''height'' (defaults at 440 / 330).
Save the following file as ''video.php'' under plugins/actions folder:
%%(php)
$value)
{
if ($param == 'src' && $vars['url'] == '') {$vars['url']=$value;}
if ($param == 'type') {$type = $this->htmlspecialchars_ent($vars['type']);}
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(isset($vars['url'])) $url = $this->cleanUrl(trim($vars['url']));
if($id == '' && $url != '') {
if ( preg_match('/^.*www.(.*?)\..*?\/(.*)$/', $url, $matches) ) {
// $matches[1] is domain; youtube or vimeo etc. - $matches[2] is everything after the first slash.
$type = $matches[1];
if ( $type == 'youtube' ) {
if ( preg_match('/watch\?v=(.*?)(\&.*)?$/', $matches[2], $id_and_flags) ) {
$id = $id_and_flags[1];
} else {
$errors .= "bad format on youtube arguments: $matches[2]";
}
} else if ( $type == 'vimeo' ) {
$id = $matches[2];
} else {
$errors .= "type: <$type> not known or bad id: <$id> in url.";
}
} else {
$errors .= 'no id and error in url: ' . $url . "\n";
}
}
// building output
if ( $id != '' ) {
if ($type == 'youtube' && $id != '') {
$output = '' . "\n";
} else if ($type == 'vimeo') {
$output = '' . "\n";
}
} else { $output = $errors; }
echo $output;
?>
%%
----
CategoryDevelopmentActions CategoryUserContributions