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
Switch to threaded view of this topic Create a new topic Submit Reply
Youtube plugin mod [message #163725] Thu, 25 November 2010 14:59 Go to next message
Martin_E is currently offline  Martin_E
Messages: 16
Registered: November 2010
Karma: 0
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

Re: Youtube plugin mod [message #163726 is a reply to message #163725] Thu, 25 November 2010 15:40 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Great job!

Maybe we should try to combine the two versions (to handle links & tags). I'll see what I can do later...
Aw: Re: Youtube plugin mod [message #163727 is a reply to message #163726] Thu, 25 November 2010 17:08 Go to previous messageGo to next message
Martin_E is currently offline  Martin_E
Messages: 16
Registered: November 2010
Karma: 0
Junior Member
I prefer to let it separate, so the admin can choose the activation. May we can name it youtube_urltag.plugin

[Updated on: Thu, 25 November 2010 17:10]

Report message to a moderator

Re: Aw: Re: Youtube plugin mod [message #163729 is a reply to message #163727] Thu, 25 November 2010 22:50 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
We are not going to ship FUDforum with multiple YouTube plugins.
You are obviously welcome to call your plugin whatever you like and to even publish it on the FUDforum wiki.
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Fri Nov 01 01:05:15 GMT 2024

Total time taken to generate the page: 0.01927 seconds