MyBB Community Forums

Full Version: [tutorial]Another My Youtube Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I saw some youtube mycode on the board but this is a different one.
this MyCode will allow you to copy full URL of youtube and just put in MyCode like that

[youtube]http://www.youtube.com/watch?v=xxxxxxx[/youtube]

Go to ACP -> Configuration ->MyCode -> Add New MyCode

And put the following values to your new Mycode:

Title
Youtube
Short Description
youtube video code
Regular Expression
\[youtube\]http:\/\/(.*?)youtube.com\/watch\?v\=(.*?)\[/youtube\]
Replacement
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/$2"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$2" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
Enabled?
yes

Save it and it was!

For testing

Test Value:
[youtube]http://www.youtube.com/watch?v=sZp3Gjpltc4[/youtube]

^^mike16os
Worked fine, gretly explain, thankx dude
Does it support International Youtube considering there are a lot of UK members on forum and members from other countries.
(2009-03-24, 01:23 PM)Hapatio Wrote: [ -> ]Does it support International Youtube considering there are a lot of UK members on forum and members from other countries.

Yes it supports international youtube URL.
It was testing with de.youtube.com
But it also shold work with all kind of xx.youtube.com subdomain.

^^mike
Thank you very much! This mycode works! I had a plugin for this and the video wouldn't play. Thanks!Wink
Good idea,

thanks... Smile
Small question if I may. How would I add a MyCode button for YouTube?
(2009-06-21, 09:12 AM)John Briggs Wrote: [ -> ]Small question if I may. How would I add a MyCode button for YouTube?

http://community.mybboard.net/thread-12693.html
The regexp I wrote looks like this:

\[youtube\](.*?)(youtube.com/watch\?v=)?([A-Za-z0-9\-\_"']+)[&\w;=\+_\-]*\[/youtube\]

I pull argument $3. The regexp will match and extract your movie id from any of the following (since so much is optional):

http://www.youtube.com/watch?v=sZp3Gjpltc4&feature=fvw
http://www.youtube.com/watch?v=sZp3Gjpltc4
www.youtube.com/watch?v=sZp3Gjpltc4
de.youtube.com/watch?v=sZp3Gjpltc4
youtube.com/watch?v=sZp3Gjpltc4
sZp3Gjpltc4

The single and double quote chars are not valid characters in the movie id, but they are in my expression so that people can't inject code into the object tag.
shiphorns, dont work for me Sad