FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Youtube plugin mod (modified Youtube plugin, without BB-Code)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Youtube plugin mod [message #163725] Thu, 25 November 2010 14:59 Go to previous message
Martin_E is currently offline  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

[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem sending e-mail from the forum
Next Topic: HELP!! Our forum has disappeared
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 12:25:41 GMT 2024

Total time taken to generate the page: 0.04188 seconds