MyBB Community Forums

Full Version: (Tutorial) Mycode Youtube 720p [HD on] by default]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Go to your ACP in:
www.yoursite.com/admin/index.php?module=config/mycode

Follow these steps in creating a new mycode

Title: Youtube HD

Short Description: YoutubeHD

Regular Expression:
\[video=hd\]([0-9a-zA-Z\-_ ]+)\[/video\]

Replacement:
<object width="854" height="450"><param name="movie" value="http://www.youtube.com/v/$1&hl=pt-br&fs=1&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$1&hl=pt-br&fs=1&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="854" height="450"></embed></object>

PS: Replace pt-br with with your language code



Result:
[attachment=13889]
will this make it though for people who have a youtube video url can just copy it to the site and post reply and voila there is the youtube video and then you start to watch it?
nope... bbcode for this will be

[video=hd]video-ID[/video]

(2009-05-12, 11:23 AM)Yumi Wrote: [ -> ]I've seen a number of MyCodes where "(.*?)" expression is used. I thought it'd be about time that I suggest trying to avoid that expression where possible, as this may allow users to perform some minor HTML injection (HTML tags are automatically converted to their entities and Javascript is automatically stripped out, so luckily this isn't that big an issue).

Suggestions:
Number fields, use "([0-9]+)"
General CSS fields (may not apply to everything), use "([0-9a-zA-Z\-_ ]+)"

Hope that helps.

Updated...