YouTube视频短网址插入Discuz!X播放

最常见的youtube视频网址有以下两种:

http://www.youtube.com/watch?v=<youtube_id>
http://youtu.be/<youtube_id>

示例插入:
打开Discuz!X编辑器,视频插入youtube短网址

http://youtu.be/_XV77W2OAJs

插入后代码为:

[media=x,500,375]http://youtu.be/_XV77W2OAJs[/media]

修改方法:
打开function_discuzcode.php文件,
查找:

} elseif(strpos($lowerurl, 'tv.mofile.com/') !== FALSE) {

上面加:

//------------------------------------------------------------------
} elseif(strpos($lowerurl, 'youtu.be/') !== FALSE) {
if(preg_match("/http:\/\/youtu.be\/([^\/]+)/i", $url, $matches)) {
$flv = 'http://www.youtube.com/v/'.$matches[1].'?version=3&amp;hl=zh_TW&amp;rel=0';
if(!$width && !$height) {
$str = file_get_contents("http://www.youtube.com/embed/".$matches[1]);
if(!empty($str) && preg_match("/\"iurl\": \"(.+?)\",/i", $str, $image)) {
$imgurl = trim(str_replace('\\', '', $image[1]));
}
}
}
} elseif(strpos($lowerurl, 'vlog.xuite.net/play') !== FALSE) {
if(preg_match("/http:\/\/vlog.xuite.net\/play\/(.*?)/i", $url, $matches)) {
$str = file_get_contents($url);
preg_match("/\"og:video\" content=\"(.+?)\"/i", $str, $video);
$flv = trim($video[1]);
if(!$width && !$height) {
if(!empty($str) && preg_match("/\"og:image\" content=\"(.+?)\"/i", $str, $image)) {
$imgurl = trim($image[1]);
}
}
}
//------------------------------------------------------------------

 

随机文章:

1、锁定你的网站,不让网页在其它人的框架内出现。
https://www.onexin.net/lock-your-website-and-not-to-pages-within-the-framework-of-other-people/

2、[个人潜能力8A]克服失败和成功的恐惧和克服被拒绝的恐惧
https://www.onexin.net/personal-latent-capacity-of-a-to-overcome-the-fear-of-failure-and-success-and-overcome-the-fear-of-being-rejected/

3、继Magento中文简繁体版之后开发Cantonese粤语版
https://www.onexin.net/following-the-simplified-and-traditional-chinese-version-of-magento-developed-after-cantonese-cantonese-version/

4、JDBC中PreparedStatement接口提供的execute、executeQuery和executeUpdate之间的区别及用法
https://www.onexin.net/the-difference-between-and-usage-of-jdbc-preparedstatement-interface-provides-the-execute-executequery-and-executeupdate/

5、创建CA证书和SERVER服务器证书
https://www.onexin.net/ca-server-cert/

转载请注明出处:https://www.onexin.net/let-discuz-x-support-insert-youtube-video-short-url/

Leave a Reply

Your email address will not be published. Required fields are marked *