0

I have a condition whereby:

if( has_post_thumbnail() ){
    return get_the_post_thumbnail();
}

However, I would like that condition to be valid for all images's extensions, except for .gif.

How can I achieve that?

My ultimate goal is not to be taken to the article when the featured image on the home is .gif.

1 Answer 1

4

If you want to check the mime type of the featured image, then one way could be to use get_post_thumbnail_id() to get it's ID and then check the mime type with get_post_mime_type() :

if( has_post_thumbnail() && 'image/gif' !== get_post_mime_type( get_post_thumbnail_id() ) {
    return get_the_post_thumbnail();
}

where you return it for non-gifs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.