欢迎光临 - 我的站长站,本站所有资源仅供学习与参考,禁止用于商业用途或从事违法行为!

wordpress教程

WordPress修改GIF动图上传方法

wordpress教程 我的站长站 2019-06-18 共119人阅读

由于wordpress后台上传图片时会自动剪切,所以有些上传了gif特色图片后,在前台显示时是被剪切成了静态图片,这里模板兔教大家一个方法,将下面的代码整合到主题里:

if( get_the_post_thumbnail() ){$thumb_url = get_the_post_thumbnail_url();$thumb_low = strtolower($thumb_url);if (strpos($thumb_low, '.gif') === false) {$thumb_size = 'thumbnail';} else {$thumb_size = 'full';}the_post_thumbnail($thumb_size);}

就是在获取特色图片时(后台单独上传的特色图片)判断其后缀然后设置其缩略图大小为原图即可。