分享视频增加缩略图
2011-03-23 18:34
525 查看
以下是修改方法(特别说明,修改前做好备份
):
修改cp_share.php 408行起以下内容
if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn)$/i", $parseLink['host'], $hosts)) {
$flashvar = getflash($link, $hosts[1]);
if(!empty($flashvar)) {
$arr['title_template'] = cplang('share_video');
$type = 'video';
$arr['body_data']['flashvar'] = $flashvar;
$arr['body_data']['host'] = $hosts[1];
}
}
修改为:
if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn|tudou.com)$/i",
$parseLink['host'], $hosts)) {
$flashvar = getflash($link, $hosts[1]);
$flashimg = getflashimg($link, $hosts[1]);
if(!empty($flashvar)) {
$arr['title_template'] = cplang('share_video');
$type = 'video';
$arr['body_data']['flashvar'] = $flashvar;
$arr['body_data']['host'] = $hosts[1];
if(!empty($flashimg)){
$arr['image'] = $flashimg;
}
}
}
找到这个函数:
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
// http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html]http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html[/url]
preg_match_all("/id/_(/w+)[=.]/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('ku6.com' == $host) {
// +)/.html/", $link, $matches);
if(1 > preg_match("///index_([/w/-]+)/.html/", $link) && !empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('youtube.com' == $host) {
// [url=http://tw.youtube.com/watch?v=hwHhRcRDAN0]http://tw.youtube.com/watch?v=hwHhRcRDAN0
preg_match_all("/v/=([/w/-]+)/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('5show.com' == $host) {
// http://www.5show.com/show/show/160944.shtml
preg_match_all("///(/d+)/.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('mofile.com' == $host) {
// http://tv.mofile.com/PPU3NTYW/
preg_match_all("///(/w+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sina.com.cn' == $host) {
// http://you.video.sina.com.cn/b/16776316-1338697621.html
preg_match_all("///(/d+)-(/d+)/.html/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sohu.com' == $host) {
// http://v.blog.sohu.com/u/vw/1785928
preg_match_all("///(/d+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
}
return $return;
}
修改为:
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
// http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html]http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html[/url]
preg_match_all("/id/_(/w+)[=.]/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('ku6.com' == $host) {
// +)/.html/", $link, $matches);
if(1 > preg_match("///index_([/w/-]+)/.html/", $link) && !empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('youtube.com' == $host) {
// http://tw.youtube.com/watch?v=hwHhRcRDAN0]http://tw.youtube.com/watch?v=hwHhRcRDAN0
preg_match_all("/v/=([/w/-]+)/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('5show.com' == $host) {
// http://www.5show.com/show/show/160944.shtml]http://www.5show.com/show/show/160944.shtml[/url]
preg_match_all("///(/d+)/.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('mofile.com' == $host) {
// http://tv.mofile.com/PPU3NTYW/]http://tv.mofile.com/PPU3NTYW/[/url]
//http://v.mofile.com/show/HLD5PLD2.shtml
preg_match_all("///([/w/-]+)/.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sina.com.cn' == $host) {
// [url=http://you.video.sina.com.cn/b/16776316-1338697621.html
preg_match_all("///(/d+)-(/d+)/.html/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sohu.com' == $host) {
// [url=http://v.blog.sohu.com/u/vw/1785928
preg_match_all("///(/d+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('tudou.com' == $host) {
// [url=http://www.tudou.com/programs/view/oOrUqgezkOc/
preg_match_all("///([/w/-]+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
}
return $return;
}
function getflashimg($link, $host) {
$return='';
$content = file_get_contents($link);//获取
if('tudou.com' == $host)
{
preg_match_all("/<span class=/"s_pic/">(.*?)<//span>/i",$content,$img);
}
elseif('youku.com' == $host)
{
preg_match_all("//+0800/|(.*?)/|/">/i",$content,$img);
//$img = $img[1][0];
}
elseif('ku6.com' == $host)
{
preg_match_all("/<span class=/"s_pic/">(.*?)<//span>/i",$content,$img);
}
elseif('mofile.com' == $host)
{
preg_match_all("/thumbpath=/"(.*?)/";/i",$content,$img);
}
$img = $img[1][0];
if($img){
$return $img;
}
}
上面同时修改了mofile视频的bug,增加了支持土豆视频。
修改模板文件space_share_li.htm 找到(大约15行):
<!--{if $value['image']}-->
<a href="$value[image_link]"><img src="$value[image]" class="summaryimg image" alt="" width="70" /></a>
<!--{/if}-->
修改为:
<!--{if $value['image'] && 'video'!=$value['type']}-->
<a href="$value[image_link]"><img src="$value[image]" class="summaryimg image" alt="" width="70" /></a>
<!--{/if}-->
找到(22行左右):
<div class="media">
<img src="image/vd.gif" alt="点击播放" style="cursor:pointer;" />
</div>
修改为:
<div class="media">
<img src="<!--{if
!empty($value['image'])}-->$value[image]<!--{else}-->/image/vd.gif<!--{/if}-->"
alt="点击播放" style="cursor:pointer;" />
</div>
以上借用了feed表中的image字段,免得修改表结构了
然后是修改space_feed_li.htm
找到:
<!--{if $value['image_1']}-->
<a href="$value[image_1_link]"{$value[target]}><img src="$value[image_1]" class="summaryimg" /></a>
<!--{/if}-->
修改为:
<!--{if $value['image_1'] && empty($value['body_data']['flashvar'])}-->
<a href="$value[image_1_link]"{$value[target]}><img src="$value[image_1]" class="summaryimg" /></a>
<!--{/if}-->
发的仓促,以下内容漏掉了,现补上,feed页没有显示缩略图的注意一下
在大约48行找到
<div class="media">
<img src="image/vd.gif" alt="点击播放"
onclick="javascript:showFlash('{$value['body_data']['host']}',
'{$value['body_data']['flashvar']}', this, '{$value['feedid']}');"
style="cursor:pointer;" />
</div>
修改为
<div class="media">
<img src="<!--{if
!empty($value['image_1'])}-->$value[image_1]<!--{else}-->/image/noimg.gif<!--{/if}-->"
alt="点击播放"
onclick="javascript:showFlash('{$value['body_data']['host']}',
'{$value['body_data']['flashvar']}', this, '{$value['feedid']}');"
style="cursor:pointer;" />
</div>
):
修改cp_share.php 408行起以下内容
if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn)$/i", $parseLink['host'], $hosts)) {
$flashvar = getflash($link, $hosts[1]);
if(!empty($flashvar)) {
$arr['title_template'] = cplang('share_video');
$type = 'video';
$arr['body_data']['flashvar'] = $flashvar;
$arr['body_data']['host'] = $hosts[1];
}
}
修改为:
if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn|tudou.com)$/i",
$parseLink['host'], $hosts)) {
$flashvar = getflash($link, $hosts[1]);
$flashimg = getflashimg($link, $hosts[1]);
if(!empty($flashvar)) {
$arr['title_template'] = cplang('share_video');
$type = 'video';
$arr['body_data']['flashvar'] = $flashvar;
$arr['body_data']['host'] = $hosts[1];
if(!empty($flashimg)){
$arr['image'] = $flashimg;
}
}
}
找到这个函数:
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
// http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html]http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html[/url]
preg_match_all("/id/_(/w+)[=.]/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('ku6.com' == $host) {
// +)/.html/", $link, $matches);
if(1 > preg_match("///index_([/w/-]+)/.html/", $link) && !empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('youtube.com' == $host) {
// [url=http://tw.youtube.com/watch?v=hwHhRcRDAN0]http://tw.youtube.com/watch?v=hwHhRcRDAN0
preg_match_all("/v/=([/w/-]+)/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('5show.com' == $host) {
// http://www.5show.com/show/show/160944.shtml
preg_match_all("///(/d+)/.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('mofile.com' == $host) {
// http://tv.mofile.com/PPU3NTYW/
preg_match_all("///(/w+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sina.com.cn' == $host) {
// http://you.video.sina.com.cn/b/16776316-1338697621.html
preg_match_all("///(/d+)-(/d+)/.html/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sohu.com' == $host) {
// http://v.blog.sohu.com/u/vw/1785928
preg_match_all("///(/d+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
}
return $return;
}
修改为:
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
// http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html]http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html[/url]
preg_match_all("/id/_(/w+)[=.]/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('ku6.com' == $host) {
// +)/.html/", $link, $matches);
if(1 > preg_match("///index_([/w/-]+)/.html/", $link) && !empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('youtube.com' == $host) {
// http://tw.youtube.com/watch?v=hwHhRcRDAN0]http://tw.youtube.com/watch?v=hwHhRcRDAN0
preg_match_all("/v/=([/w/-]+)/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('5show.com' == $host) {
// http://www.5show.com/show/show/160944.shtml]http://www.5show.com/show/show/160944.shtml[/url]
preg_match_all("///(/d+)/.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('mofile.com' == $host) {
// http://tv.mofile.com/PPU3NTYW/]http://tv.mofile.com/PPU3NTYW/[/url]
//http://v.mofile.com/show/HLD5PLD2.shtml
preg_match_all("///([/w/-]+)/.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sina.com.cn' == $host) {
// [url=http://you.video.sina.com.cn/b/16776316-1338697621.html
preg_match_all("///(/d+)-(/d+)/.html/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sohu.com' == $host) {
// [url=http://v.blog.sohu.com/u/vw/1785928
preg_match_all("///(/d+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('tudou.com' == $host) {
// [url=http://www.tudou.com/programs/view/oOrUqgezkOc/
preg_match_all("///([/w/-]+)//*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
}
return $return;
}
function getflashimg($link, $host) {
$return='';
$content = file_get_contents($link);//获取
if('tudou.com' == $host)
{
preg_match_all("/<span class=/"s_pic/">(.*?)<//span>/i",$content,$img);
}
elseif('youku.com' == $host)
{
preg_match_all("//+0800/|(.*?)/|/">/i",$content,$img);
//$img = $img[1][0];
}
elseif('ku6.com' == $host)
{
preg_match_all("/<span class=/"s_pic/">(.*?)<//span>/i",$content,$img);
}
elseif('mofile.com' == $host)
{
preg_match_all("/thumbpath=/"(.*?)/";/i",$content,$img);
}
$img = $img[1][0];
if($img){
$return $img;
}
}
上面同时修改了mofile视频的bug,增加了支持土豆视频。
修改模板文件space_share_li.htm 找到(大约15行):
<!--{if $value['image']}-->
<a href="$value[image_link]"><img src="$value[image]" class="summaryimg image" alt="" width="70" /></a>
<!--{/if}-->
修改为:
<!--{if $value['image'] && 'video'!=$value['type']}-->
<a href="$value[image_link]"><img src="$value[image]" class="summaryimg image" alt="" width="70" /></a>
<!--{/if}-->
找到(22行左右):
<div class="media">
<img src="image/vd.gif" alt="点击播放" style="cursor:pointer;" />
</div>
修改为:
<div class="media">
<img src="<!--{if
!empty($value['image'])}-->$value[image]<!--{else}-->/image/vd.gif<!--{/if}-->"
alt="点击播放" style="cursor:pointer;" />
</div>
以上借用了feed表中的image字段,免得修改表结构了
然后是修改space_feed_li.htm
找到:
<!--{if $value['image_1']}-->
<a href="$value[image_1_link]"{$value[target]}><img src="$value[image_1]" class="summaryimg" /></a>
<!--{/if}-->
修改为:
<!--{if $value['image_1'] && empty($value['body_data']['flashvar'])}-->
<a href="$value[image_1_link]"{$value[target]}><img src="$value[image_1]" class="summaryimg" /></a>
<!--{/if}-->
发的仓促,以下内容漏掉了,现补上,feed页没有显示缩略图的注意一下
在大约48行找到
<div class="media">
<img src="image/vd.gif" alt="点击播放"
onclick="javascript:showFlash('{$value['body_data']['host']}',
'{$value['body_data']['flashvar']}', this, '{$value['feedid']}');"
style="cursor:pointer;" />
</div>
修改为
<div class="media">
<img src="<!--{if
!empty($value['image_1'])}-->$value[image_1]<!--{else}-->/image/noimg.gif<!--{/if}-->"
alt="点击播放"
onclick="javascript:showFlash('{$value['body_data']['host']}',
'{$value['body_data']['flashvar']}', this, '{$value['feedid']}');"
style="cursor:pointer;" />
</div>
相关文章推荐
- uchome分享视频增加缩略图功能
- uchome2.0 分享部分增加视频缩图
- 显示youtube视频缩略图和Vimeo视频缩略图代码分享
- jQuery上传文件到服务器,实现量上传及压缩包导入,支持Office文档、PDF、图像、音视频和图纸等各类型文件。上传完成后系统自动为图片、音、视频类文件增加摘要及缩略图
- 微信分享缩略图,如何增加微信朋友圈分享链接的小图片? facebook、google+、twitter等分享的标签
- jquery点击缩略图切换视频播放特效代码分享
- camera录制视频的缩略图获取原理心得分享
- 显示youtube视频缩略图和Vimeo视频缩略图代码分享
- ucenter home 视频增加缩略图
- jquery点击缩略图切换视频播放特效代码分享
- 分享给大家一个比较正规的java坦克大战教学视频,希望对那些想学Java的人有些帮助
- 2014年视频聊天室开发经验分享
- 2014年视频聊天室开发经验分享
- 高清视频教程网站的搭建和分享
- 干货!java经典面试套路精讲视频教程免费分享!
- java经典面试题深度解析免费视频教程分享
- Android接入微信分享视频和图片
- 视频文件缩略图
- 从“阿北的知识分享”新增视频模板消息推送开始说yii2队列
- iOS 获取本地视频的缩略图