Re: Plugin: YouTube in bbPress
I use this plugin ported from a Vanilla Extension:
<?php
/*
Plugin Name: Video Tags
Plugin URI: http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=33
Description: Ported from SirNot's HtmlFormatter for Vanilla
Author URI:
Version: 0.1
*/
//allow youtube and google videos to be posted, tags are:
//<video type="google">docid</video> (google video) -or-
//<video type="youtube">video id</video> (youtube) -or-
function video_embed($texto){
$sReturn = preg_replace_callback(
'/<video(?>s+)type=(["'
])((?>w+))1(?>s*)>([A-Za-z-_d]+?)</video>/is’,
‘VideoLink’,
$texto
);
return $sReturn;
}
function VideoLink($Matches)
{
$Type = strtolower(trim($Matches[2]));
$ID = $Matches[3];
switch($Type)
{
case ‘google’ : return (‘<embed style=”width: 400px; height: 326px;” id=”VideoPlayback” ‘.
‘type=”application/x-shockwave-flash” src=”http://video.google.com/googleplayer.swf?docId=’.$ID.'”></embed>’);
case ‘youtube’ : return (‘<object width=”425″ height=”350″><param name=”movie” value=”http://www.youtube.com/v/’.$ID.'”></param>’.
‘<embed src=”http://www.youtube.com/v/’.$ID.'” type=”application/x-shockwave-flash” width=”425″ height=”350″></embed>’.
‘</object>’);
default : return $Matches[0];
}
}
function allow_video_tags( $tags ) {
$tags = array(‘type’ => array(‘maxlen’ => 10));
return $tags;
}
add_filter( ‘bb_allowed_tags’, ‘allow_video_tags’ );
add_filter( ‘post_text’, ‘video_embed’ );
?>
`
It allows you to embed video only from YT or Google Video.