會員註冊 / 登入  |  電腦版  |  Jump to bottom of page

JForum中文社群 JForum Chinese Users Community » Add YouTube BB Code support for JForum

發表人: andowson, 七段學員
2007-07-14 13:16:44
add the following code at the bottom of bb_config.xml:

<match name="youtube">
<regex>(?i)\[youtube\]http\:\/\/www.youtube.com\/watch\?v\=(.*?)\[/youtube\]</regex>
<replace>
<![CDATA[
<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/$1"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
</object>
]]>
</replace>
</match>

go to Admin Panel -> Cache -> Reload BB Code and it's done.

Usage:
[youtube]full URL of the YouTube Video[/youtube]


See http://www.andowson.com/posts/list/109.page for live demo.

發表人: andowson, 七段學員
2008-01-05 00:49:32
The original post only supports URL in the form "www.youtube.com". However, if you change to another form, like "youtube.com" or "tw.youtube.com", it will not work. So, we need to modify the original bb_config.xml as follows:

<!-- YouTube -->
<match name="youtube">
<regex>
(?i)\[youtube\]http\:\/\/(.*?)youtube.com\/watch\?v\=(.*?)\[/youtube\]
</regex>
<replace>
<![CDATA[
<object width="450" height="370">
<param name="movie" value="http://$1youtube.com/v/$2"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://$1youtube.com/v/$2" type="application/x-shockwave-flash" wmode="transparent" width="450" height="370"></embed>
</object>
]]>
</replace>
</match>

Now, the new form of URL works.

See:
http://www.jforum.net/posts/list/4269.page




會員註冊 / 登入  |  電腦版  |  Jump to top of page