//timthumb缩略图函数 已经把域名全部加上,好用七牛空间镜像
function post_thumbnail($width, $height, $dataSrc) {
global $post;
$blogUrl = 'http://' . $_SERVER['HTTP_HOST'];
$isTimThumb = get_option('themes_fo2_TimThumb');
$first_img_src = catch_that_image();
$timthumbFlod = str_replace($blogUrl, '', get_bloginfo("template_url"));;
if (has_post_thumbnail()) { //如果有缩略图,则显示缩略图
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'full');
$timthumb_src = str_replace($blogUrl, '', $timthumb_src[0]);
if (isset($dataSrc)) {
if (!$isTimThumb) {
$post_timthumb = '<img ' . $dataSrc . '="' . $timthumbFlod . '/timthumb.php?src=' . $timthumb_src . '&h=' . $height . '&w=' . $width . '&zc=1" alt="' . $post->post_title . '" />';
} else {
$post_timthumb = '<img ' . $dataSrc . '="' . $timthumb_src . '" height="' . $height . '" width="' . $width . '" alt="' . $post->post_title . '" />';
}
} else {
if (!$isTimThumb) {
$post_timthumb = '<img src=' . $timthumbFlod . '/timthumb.php?src=' . $timthumb_src . '&h=' . $height . '&w=' . $width . '&zc=1" alt="' . $post->post_title . '" />';
} else {
$post_timthumb = '<img src="' . $timthumb_src . '" height="' . $height . '" width="' . $width . '" alt="' . $post->post_title . '" />';
}
}
if (isset($timthumb_src{5})) {
echo $post_timthumb;
}
} else {
$first_img_src = str_replace($blogUrl, '', $first_img_src);
if (!empty($first_img_src)) { //如果日志中有图片
if (isset($dataSrc)) {
if (!$isTimThumb) {
$post_timthumb = '<img ' . $dataSrc . '="' . $timthumbFlod . '/timthumb.php?src=' . $first_img_src . '&h=' . $height . '&w=' . $width . '&zc=1" alt="' . $post->post_title . '" />';
} else {
$post_timthumb = '<img ' . $dataSrc . '="' . $first_img_src . '" height="' . $height . '" width="' . $width . '" alt="' . $post->post_title . '" />';
}
} else {
if (!$isTimThumb) {
$post_timthumb = '<img src="' . $timthumbFlod . '/timthumb.php?src=' . $first_img_src . '&h=' . $height . '&w=' . $width . '&zc=1" alt="' . $post->post_title . '" />';
} else {
$post_timthumb = '<img src="' . $first_img_src . '" height="' . $height . '" width="' . $width . '" alt="' . $post->post_title . '" />';
}
}
} else { //如果日志中没有图片,则显示默认
if (isset($dataSrc)) {
$post_timthumb = '<img ' . $dataSrc . '="' . get_bloginfo("template_url") . '/images/default_thumb.gif" alt="' . $post->post_title . '" />';
} else {
$post_timthumb = '<img src="' . get_bloginfo("template_url") . '/images/default_thumb.gif" alt="' . $post->post_title . '" />';
}
}
echo $post_timthumb;
}
} 收藏的用户(0) X
正在加载信息~
推荐阅读
最新回复 (1)
-
itandfielnori 2017-4-6引用 2楼备份别人的代码,以防后期使用
站点信息
- 文章2313
- 用户1336
- 访客11756458
每日一句
Life is short; Live it!
人生苦短,活出精彩。
人生苦短,活出精彩。
信鸽推送报错NSObject checkTargetOtherLinkFlagForObjc
简单利用Clover四叶草安装U盘安装黑苹果
学习使用Java注解
OllyDbg中如何找出B模块中所有调用了A模块的C方法的地方
解决SSH客户端中文乱码
10年后,Android应用程序仍然比iOS应用程序差
C++11特性里面的thread
XPosed微信自动生成二维码
解决android studio "found an invalid color"的问题
T9社区注册方法【勼适様鲃女尔懟死】
Thinkpad x1 Extreme黑苹果10.14.5安装完成
基于大白主题增加图片本地化的功能
Linux系统查看CPU使用率的几个命令
新会员