PHPBB Optimal YouTube BBCode

Dimitris Damilos picture Dimitris Damilos · Mar 10, 2012 · Viewed 7.8k times · Source

Anyone knows the optimal bbcode to embed youtube videos in PHPBB3? I use the follwing:

BBCode Usage:

[youtube]http://{SIMPLETEXT1}youtube.com/watch?v={SIMPLETEXT2}[/youtube]

HTML Replacement:

<object width="560" height="315">
    <param name="movie" value="http://{SIMPLETEXT1}youtube.com/v/{SIMPLETEXT2}"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="http://{SIMPLETEXT1}youtube.com/v/{SIMPLETEXT2}" 
           type="application/x-shockwave-flash" 
           width="560" 
           height="315" 
           allowscriptaccess="always" 
           allowfullscreen="true">
    </embed>
</object>

This seems to have some issues and doesn't translate to HTML when the URL the user puts is something like http://www.youtube.com/watch?v=vS6VBOeJ-i4&feature=related.

I would like to make an HTML Replacement so it can replace the user's link into the new embed style of YouTube with the iFrame, but independent of URL attributes while also using the wmode=transparent, since I also use Shadowbox.

Answer

Gary Woods picture Gary Woods · Sep 13, 2012

While riot_starter's solution works, it does not seem to work with https URLs which YouTube forces nowdays. So here is a workaround that should work in all scenarios:

BBCode:

[youtube]http{TEXT4}://{TEXT1}youtube.com/{TEXT2}v={IDENTIFIER}{TEXT3}[/youtube]

HTML:

<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/{IDENTIFIER}&hl=en_US&fs=1&"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/{IDENTIFIER}&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="350"></embed>
</object>