为discuz编辑器添加youtube视频代码按钮

设置方法:
登陆论坛后台–style–editor setting–discuz! code 添加youtube项并上传小图标至images/common 目录内;
在details 里设置 替换内容 为






最后设置youtube项为 Available Display

此时会员发帖时编辑器上会出现youtube按钮,会员需输入视频id,即分享地址(http://www.youtube.com/watch?v=6WgMwd6AgU0)中的6WgMwd6AgU0,为方便会员输入需要修改include/discuzcode.func.php文件
7.2修改方法

preg_replace(array(

   "/\[color=([#\w]+?)\]/i",

   "/\[size=(\d+?)\]/i",

   "/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/i",

   "/\[font=([^\[\<]+?)\]/i",

   "/\[align=(left|center|right)\]/i",

   "/\[p=(\d{1,2}), (\d{1,2}), (left|center|right)\]/i",

   "/\[float=(left|right)\]/i",

   "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[\/youtube\]#is"  //此行为添加代码

  ), array(

   "",

   "",

   "",

   "",

   "

", "

", "", "[youtube]\\1[/youtube]" //此行为添加代码 )

6.0修改方法

   $discuzcodes['searcharray']['bbcode_regexp'] = array(

    "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[\/youtube\]#is",     //此行为添加代码

    "/\[url\]\s*(www.|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|bctp:\/\/|ed2k:\/\/|thunder:\/\/|synacast:\/\/){1}([^\[\"']+?)\s*\[\/url\]/ie",

    "/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/is",

    "/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/is",

    "/\[email\]\s*([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+)\s*\[\/email\]/i",

    "/\[email=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+)\](.+?)\[\/email\]/is",

    "/\[color=([#\w]+?)\]/i",

    "/\[size=(\d+?)\]/i",

    "/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/i",

    "/\[font=([^\[\<]+?)\]/i",

    "/\[align=(left|center|right)\]/i",

    "/\[float=(left|right)\]/i"

   );

   $discuzcodes['replacearray']['bbcode_regexp'] = array(

    "[youtube]\\1[/youtube]",           //此行为添加代码

    "cuturl('\\1\\2')",

    "\\2",

    "\\3",

    "\\1@\\2",

    "\\3",

    "",

    "",

    "",

    "",

    "

", "" );

经过修改会员在添加youtube视频时可以直接输入视频分享地址(http://www.youtube.com/watch?v=6WgMwd6AgU0)即可

参考地址:http://www.alan888.com/Discuz/thread-160793-1-1.html