//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楼备份别人的代码,以防后期使用
站点信息
- 文章2303
- 用户1336
- 访客11134080
每日一句
Plan something big by starting with small steps.
从小处着手,规划大事。
从小处着手,规划大事。
IDEA创建SpringBoot项目详细步骤
找回SecureCRT密码
阿里云再次搬迁笔记
已经存在的Android Studio工程添加NDK支持
ndk神奇问题之non-numeric second argument to `wordlist' function: '8.7z'
请启用虚拟机平台 windows 功能并确保在 bios 中启用虚拟化
iOS公司账号($99)/企业账号($299)申请
Android 8.0应用图标适配
VirtualXposed,让你无需Root也能使用Xposed框架!
【收藏】xiunobbs近期关站,可能后会无期了!
IDEA 2018创建Netty工程——入门篇
发几个实用的chrome插件
语法错误: 意外的令牌“标识符”
新会员