Youtube plugin mod [message #163725] |
Thu, 25 November 2010 14:59 |
|
Martin_E
Messages: 16 Registered: November 2010
Karma:
|
Junior Member |
|
|
Some of forum users would like to copy an paste the URL of a youtube video.
The user can easily put the URL into a message, e.g.:
http://www.youtube.com/watch?v=9vgicLc0W-g
Here is my modification of this plugin.
<?php
/**
* copyright : (C) IT-Systemberatung Martin Eller
* email : mail(at)eller-it(dot)de
* $Id: youtube_urltag.plugin 5021 2011-11-25 18:56:23Z meller $
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
**/
// Initialize plugin
plugin_add_hook('BBCODE2HTML', 'plugin_youtube_urltag_to_html');
plugin_add_hook('HTML2BBCODE', 'plugin_youtube_html_to_urltag');
// Convert http://www.youtube.com/watch?v=" to html code (post message)
function plugin_youtube_urltag_to_html($array) {
list($bbcode) = $array;
$bbcode = preg_replace('#http\:\/\/www\.youtube\.com\/watch\?v\=([0-9a-zA-Z_\-]+)#si', '<object width="425" height="366"><param name="movie" value="http://www.youtube.com/v/\\1"></param><embed src="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" width="425" height="366"></embed></object>', $bbcode);
return array($bbcode);
}
// Convert html to http://www.youtube.com/watch?v=" tag (edit message)
function plugin_youtube_html_to_urltag($array) {
list($bbcode) = $array;
$bbcode = preg_replace('#<object width="425" height="366"><param name="movie" value="http://www.youtube.com/v/([0-9a-zA-Z_\-]+)"></param><embed src="http://www.youtube.com/v/([0-9a-zA-Z_\-]+)" type="application/x-shockwave-flash" width="425" height="366"></embed></object>#si', 'http://www.youtube.com/watch?v=\\1', $bbcode);
return array($bbcode);
}
function youtube_urltag_info() {
return array('name' => 'Youtube Video implementation',
'desc' => 'Allow forum users to use the URL of Youtube video for embedding videos into forum posts.',
'version' => '0.9');
}
?>
Edit: Some remarks
[Updated on: Fri, 26 November 2010 05:33] Report message to a moderator
|
|
|