YouTube Mod

Get help developing custom BBCodes or request one.
Post Reply
celsiusboy
Registered User
Posts: 1
Joined: Thu Sep 05, 2013 2:51 am

YouTube Mod

Post by celsiusboy »

below work perfectly for me :)

First, we need to create a new BBCODE for YouTube. Go to the ACP > BBCodes > Add a new BBCode.

In BBCode Usage, paste this:
[YouTube]http://{SIMPLETEXT1}.youtube.com/watch?v={SIMPLETEXT2}[/YouTube]

In HTML Replacement, paste this:
<object width="630" height="460"><param name="movie" value="http://{SIMPLETEXT1}.youtube.com/v/{SIMPLETEXT2}?fs=1&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://{SIMPLETEXT1}.youtube.com/v/{SIMPLETEXT2}?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="630" height="460"></embed></object>

Make sure “Display on posting page” is ticked and submit.

Edit includes/message_parser.php. Find the line
$this->allow_url_bbcode = $allow_url_bbcode;

Insert this directly below that line:
// MOD: replace youtu.be stuff
$this->message = str_replace("youtu.be/", "www.youtube.com/watch?v=", $this->message);
$this->message = str_replace("&feature=player_embedded", "", $this->message);
//END MOD

Now, your users can paste any Youtube link in their messages, highlight them, and press a Youtube button to have them show up as embedded videos.
User avatar
exatienda.com
Registered User
Posts: 27
Joined: Sat Sep 07, 2013 12:53 pm
Contact:

Re: YouTube Mod

Post by exatienda.com »

Let me add that you can also create a BBCode with this code:

Code: Select all

<div align="center"><iframe width="625" height="515" src="http://www.youtube.com/embed/{TEXT}" frameborder="0"></iframe></div>
It is 100% W3C validated and what you have only do is use it in your posts like:

[youtube]key_of_the_video(obtained after the = of the you tube URL)[/youtube]

I use it on my forum and it's fully functional.
User avatar
Lumpy Burgertushie
Registered User
Posts: 67985
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: YouTube Mod

Post by Lumpy Burgertushie »

exatienda.com wrote:Let me add that you can also create a BBCode with this code:

Code: Select all

<div align="center"><iframe width="625" height="515" src="http://www.youtube.com/embed/{TEXT}" frameborder="0"></iframe></div>
It is 100% W3C validated and what you have only do is use it in your posts like:

[youtube]key_of_the_video(obtained after the = of the you tube URL)[/youtube]

I use it on my forum and it's fully functional.
except that using the TEXT variable inside html is a security vulnerability.

I have found the easiest youtube bbcode for the user is the following:

Code: Select all

bbcode: [youtube]{TEXT}embed/{IDENTIFIER}{TEXT2}[/youtube]

Code: Select all

html: <iframe width="420" height="315" src="http://www.youtube.com/embed/{IDENTIFIER}" frameborder="2"></iframe>

Code: Select all

help line: [youtube]copy and paste the entire iframe embed code here[/youtube]
robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
Post Reply

Return to “Custom BBCode Development and Requests”