Easy YouTube embed hack (General)

by Bubba @, Saturday, November 02, 2013, 08:20 (3829 days ago)
edited by Bubba, Saturday, November 02, 2013, 08:42

I looked all over the place and couldn't find an easy way to get YouTube embedding to work. Everything I found was either going to be a pain for me to implement, or a pain for the users, or both, so I decided to come up with my own fix. This is the absolute simplest way I can think of to get YouTube embedding to work.

In the file functions.inc.php, in the function do_bbcode_flash, place the code below just after the else and before the line:

    $html = '<!--[if IE]>

The else is at line 575 in my copy and I don't think I've added any lines of code, but you can just search for the function name.


    if (strpos($content,"http://youtu.be/") !== false) {
     $content = str_replace("http://youtu.be/", "http://www.youtube.com/v/", $content);
    }

Once that is in place you can just click on the flash button and paste a video share link in the flash url box. It don't get much simpler than that :-D

I can't guaranty it will work forever, YouTube may change their urls in the future, but until then it should be good ;-)


Complete thread:

 RSS Feed of thread