phpBB mods: bbcode for ifilm, youtube and google video embedding
I wanted to be able to embed videos from various services into forum posts on CoopersGuns Health, Fitness & BodyBuilding Forums so I decided to have a play with modifying the bbcode processor and here’s what I’ve come up with..
Modification instructions
Make the following modifications to forum/includes/bbcode.php
- Find the bbencode_first_pass function
- Locate the end of the function
// Remove our padding from the string..
return substr($text, 1);
- Add the following just before the above:
// [ifilm] and [/ifilm]
$text = preg_replace("#\[ifilm=([0-9]+[,][0-9]+[,][0-9]+)\](.*?)\[/ifilm\]#si", "[ifilm=\\1:$uid]\\2[/ifilm:$uid]", $text);
// [youtube] and [/youtube]
$text = preg_replace("#\[youtube=([0-9]+[,][0-9]+[,][0-9a-z\-_]+)\](.*?)\[/youtube\]#si", "[youtube=\\1:$uid]\\2[/youtube:$uid]", $text);
// [gvid] and [/gvid]
$text = preg_replace("#\[gvid=([0-9]+[,][0-9]+[,][0-9a-z\-_]+)\](.*?)\[/gvid\]#si", "[gvid=\\1:$uid]\\2[/gvid:$uid]", $text);
- Find the bbencode_second_pass function
- Locate the part that deals with [QUOTE]
// [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
$text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text);
$text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);
- Add the following code after the above:
// [ifilm] and [/ifilm]
$text = preg_replace("#\[ifilm=([0-9]+)[,]([0-9]+)[,]([0-9]+):$uid\](.*?)\[/ifilm:$uid\]#si", "", $text);
// [youtube] and [/youtube]
$text = preg_replace("#\[youtube=([0-9]+)[,]([0-9]+)[,]([0-9a-z\-_]+):$uid\](.*?)\[/youtube:$uid\]#si", ""."[/youtube:$uid]", $text);
$text = str_replace("[/youtube:$uid]", "", $text);
// [gvid] and [/gvid]
$text = preg_replace("#\[gvid=([0-9]+)[,]([0-9]+)[,]([0-9a-z\-_]+):$uid\](.*?)\[/gvid:$uid\]#si", ""."[/gvid:$uid]", $text);
$text = str_replace("[/gvid:$uid]", "", $text);
- Save your changes to bbcode.php and upload the modified file (if you downloaded it to modify)
That’s it.. you can now embed iFilm, YouTube and Google Video videos into your forum posts
Usage
The syntax is similar for all three:
[ifilm=width,height,id]description[/ifilm]
[youtube=width,height,id]description[/youtube]
[gvid=width,height,id]description[/gvid]
Example:
CoopersGuns Health, Fitness & BodyBuilding Forums Post
Categories: Internet, Programming, Website
Thanks for the great tip! My users have been asking for a way to put videos on the forum for a long time. This has worked great for us!
what would be an example of how the Syntax should look with a YouTube Video.
Thanks
Hey all
Does anybody know how to switch off the data execution prevention feature in Windows XP?
Hey guys,
I have an iMac G5 running tiger 10.4.7 and I an having a wierd problem. Whenever I go to a site that has an embedded youtube, flash or some kind of video, there is no sound. If it a quicktime file there is no problem. There is not sound no matter what broswer I use, firefox, camino, safari, or shiira. And keep in mind that about a week ago I was not having this issue.
Help Would be awesome
Thanks!
Heya Clark, here’s an example:
http://www.youtube.com/watch?v=Z_TvkB1-XeE
The embed code is important, holds what you need.
The code from the above mod, for the above link, would be:
[youtube=424,350,Z_TvkB1-XeE]Unicorn spotted in New York?[/youtube]
Hope that helps!
Is that possible to expand your mod to play full screen google or youtube video ?
I can’t get this to work, is this compatible with v2.0.22 of the phpBB code?
doesnt work
Wow you don’t understand how long I have been looking for a simple youtube mod like this!! Thank you thank you thank you!! this is straight foward to the point AND ONLY TOW STEPS!!. All the other sites have broken links to mods and crappy directions! anyway thought I would send you some props for this entry so thank you once again!!!
Hey do you know how to modify the code so users will only have to put the url given in youtube inside [youtube] tags?
for example,
[youtube]http://www.youtube.com/watch?v=Z_TvkB1-XeE[/youtube]
instead of specifying the width,, height and all? that will be better
hi i want to stream flash videos from my phpbb, if you can help email stevepip888@aol.com
Doesn’t work.
Beforeyougopostal.com
“Hey do you know how to modify the code so users will only have to put the url given in youtube inside [youtube] tags?”
Here is the code for utube without size parameters.
// [youtube] and [/youtube]
$text = preg_replace(“#\[youtube=([0-9a-z\-_]+):$uid\](.*?)\[/youtube:$uid\]#si”, “”.”[/youtube:$uid]“, $text);
$text = str_replace(“[/youtube:$uid]“, “”, $text);
// [youtube] and [/youtube]
$text = preg_replace(“#\[youtube=([0-9]+[,][0-9]+[,][0-9a-z\-_]+)\](.*?)\[/youtube\]#si”, “[youtube=\\1:$uid]\\2[/youtube:$uid]“, $text);
So you would enter it like this:
[youtube=Z_TvkB1-XeE]unicorn[/youtube]
still working on the other variatons…
disregard above post…it won’t let me display the code correctly!
You should authorized “embed” and “object” html tag in your forum configuration :p
Well , im from estonia so sorry when my english is not good , anyway , there was a bug for me , lucky me , because i understand php …
well , if a do , like you said to do , then i get an zero result , no video appears , so i looked up and i discovered and a bug , well , atleast for me
[/youtube:$uid]
the $uid prefix , it sucks
, i took it away and let it be just
[/youtube]
and now , it works like a charm