WordPress 让特色图片支持GIF动图

由于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);
}

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