Working Youtube BB Code - Generates iFrame Format

Get help developing custom BBCodes or request one.
Post Reply
User avatar
meleniumshane90
Registered User
Posts: 4
Joined: Thu Mar 03, 2011 9:22 am
Location: www.ThatsItGuys.com
Name: Shane Paris
Contact:

Working Youtube BB Code - Generates iFrame Format

Post by meleniumshane90 »

I was using the old BB Code for Youtube but noticed that the URLs now use https instead of http and were causing issues on new posts. Also, the code generated used Youtube's old object embedding, which doesn't scale very well for certain videos. The sharing on Youtube is now all done through iframes.

I know that using "TEXT" is not a secure solution, but is it okay to use it strictly as an input variable? Here's the code I'm using right now:

BBCode usage

Code: Select all

[youtube]{TEXT1}youtube.com/watch?v={INTTEXT2}[/youtube]
HTML replacement

Code: Select all

<iframe width="640" height="360" src="//www.youtube.com/embed/{INTTEXT2}?rel=0" frameborder="0" allowfullscreen></iframe>
All the old videos load in correctly, so it's working for our site. It works with http, https, www, m.youtube, and youtube.com URLs.

What do you guys think?
Meleniumshane90

ThatsItGuys.com
User avatar
meleniumshane90
Registered User
Posts: 4
Joined: Thu Mar 03, 2011 9:22 am
Location: www.ThatsItGuys.com
Name: Shane Paris
Contact:

Re: Working Youtube BB Code - Generates iFrame Format

Post by meleniumshane90 »

Forgot to check this for replies, but any issues with this implementation?
Meleniumshane90

ThatsItGuys.com
User avatar
Lumpy Burgertushie
Registered User
Posts: 68298
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Working Youtube BB Code - Generates iFrame Format

Post by Lumpy Burgertushie »

I am surprised that it works since you are using TEXT1 with no TEXT2 and you are using INTTEXT2 with no
INTTEXT1

however, as far as the use of TEXT it should be fine since you are not using it within an html statement.

you could change TEXT1 to SIMPLETEXT just to be sure.


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?
User avatar
JoshyPHP
Code Contributor
Posts: 1177
Joined: Mon Jul 11, 2011 12:28 am

Re: Working Youtube BB Code - Generates iFrame Format

Post by JoshyPHP »

Yeah, you can put any number of digits in those; The ordinal value doesn't matter.

By the way, that {INTTEXT2} could be {IDENTIFIER}.
I wrote the thing that does BBCodes in 3.2+.
User avatar
kamaleon
Registered User
Posts: 540
Joined: Tue Sep 09, 2014 9:47 am
Location: Barcelona

Re: Working Youtube BB Code - Generates iFrame Format

Post by kamaleon »

This is what I was looking for :)

But I am removing this part from the URL: ?rel=0

Thanks!
This is a test signature. I hope you love it :D
hershuk
Registered User
Posts: 39
Joined: Fri Jan 13, 2012 3:39 am

Re: Working Youtube BB Code - Generates iFrame Format

Post by hershuk »

Doesn't work if there is a &list= in the YT URL
User avatar
JoshyPHP
Code Contributor
Posts: 1177
Joined: Mon Jul 11, 2011 12:28 am

Re: Working Youtube BB Code - Generates iFrame Format

Post by JoshyPHP »

You can probably use something like the following, but there will always be some URLs that won't work. That's just a limitation of the custom BBCodes used in phpBB.

Code: Select all

[youtube]{TEXT1}youtube.com/watch?v={IDENTIFIER}{TEXT2}[/youtube]
I wrote the thing that does BBCodes in 3.2+.
maxslug
Registered User
Posts: 17
Joined: Sun Oct 13, 2002 10:33 pm
Location: San Francisco, CA

Re: Working Youtube BB Code - Generates iFrame Format

Post by maxslug »

This one worked for me (10/4/2014)

Code: Select all

[youtube]{IDENTIFIER}[/youtube]

Code: Select all

<iframe width="640" height="360" src="//www.youtube.com/embed/{IDENTIFIER}?rel=0&autohide=1&modestbranding=1&disablekb=1&theme=light&origin=https://YOURFORUMNAME.com/forum" frameborder="0" allowfullscreen></iframe>
Note that I've tuned a bunch of the player parameters. See all of them here:
https://developers.google.com/youtube/player_parameters
and
https://developers.google.com/youtube/i ... _reference

h2h,
-m
Post Reply

Return to “Custom BBCode Development and Requests”