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 :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Youtube plugin mod [message #163725] Thu, 25 November 2010 09:59 Go to next message
Martin_E is currently offline  Martin_E
Messages: 16
Registered: November 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 00:33]

Report message to a moderator

Re: Youtube plugin mod [message #163726 is a reply to message #163725] Thu, 25 November 2010 10:40 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3628
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
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 12:08 Go to previous messageGo to next message
Martin_E is currently offline  Martin_E
Messages: 16
Registered: November 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 12:10]

Report message to a moderator

Re: Aw: Re: Youtube plugin mod [message #163729 is a reply to message #163727] Thu, 25 November 2010 17:50 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3628
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
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.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
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: Mon Dec 11 06:29:50 EST 2017

Total time taken to generate the page: 0.00712 seconds