admin管理员组文章数量:1430578
On my wordpress site ,
I have some post that all of them have post thumbnail, but their post thumbnail removed from host and now when i want to load them on site , there is no image for loading to user ,
I want to know how can i set that if feature image is removed, show default image?
thanks
On my wordpress site ,
I have some post that all of them have post thumbnail, but their post thumbnail removed from host and now when i want to load them on site , there is no image for loading to user ,
I want to know how can i set that if feature image is removed, show default image?
thanks
1 Answer
Reset to default 1The main problem here is what exactly was removed. If only thumbnails, then you can always regenerate them and everything should work OK.
If all files are missing, then you can check if attached file is missing using this code:
if ( file_exists( get_attached_file ( get_post_thumbnail_id( $post_id ) ) ) {
// file exists
} else {
// file doesn’t exist
}
You can also use wp_attachment_is_image
function for that:
if ( wp_attachment_is_image ( get_post_thumbnail_id( $post_id ) ) {
// file exists
} else {
// file doesn’t exist
}
本文标签: How check that there is post thumbnail feature image or not on wordpress
版权声明:本文标题:How check that there is post thumbnail feature image or not on wordpress? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745442476a2658508.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论