Page 1 of 1

Working Youtube BB Code - Generates iFrame Format

Posted: Fri Aug 29, 2014 3:56 am
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?

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Thu Sep 11, 2014 12:21 pm
by meleniumshane90
Forgot to check this for replies, but any issues with this implementation?

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Thu Sep 11, 2014 1:57 pm
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

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Thu Sep 11, 2014 2:10 pm
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}.

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Mon Sep 15, 2014 8:39 pm
by kamaleon
This is what I was looking for :)

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

Thanks!

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Wed Oct 01, 2014 1:44 pm
by hershuk
Doesn't work if there is a &list= in the YT URL

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Wed Oct 01, 2014 2:01 pm
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]

Re: Working Youtube BB Code - Generates iFrame Format

Posted: Sat Oct 04, 2014 5:27 pm
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