This MOD replaces URLs to youTube videos with their embedded counterparts.
Edit 'includes/bbcode.php' and find:
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
then add:
$ret = preg_replace("#(^|[\n ]|<a(.*?)>)http://(www\.)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)(</a>)?#im",' <!-- BEGIN youtube --><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$4"></param><embed src="http://www.youtube.com/v/$4" type="application/x-shockwave-flash" width="425" height="350"></embed></object><br /><a href="http://youtube.com/watch?v=$4" target="_blank">http://youtube.com/watch?v=$4</a><!-- END youtube -->', $ret);
This works with plaintext URLs and already linked URLs, and with or without the "www".
If anyone wants to improve this code, my suggestion would be to not embed the video if it's quoted.
Any takers?
Maybe after we're done here one of the mods would drop this in the snippets section?
Cheers,
Kieran
