WordPress at Your Fingertips

wp_attachment_is_image() WP 2.1.0

Determines whether the specified post is WordPress attachment image. A conditional tag.

1 time — 0.000291 sec (fast) | 50000 times — 0.44 sec (very fast) | PHP 7.0.14, WP 4.7

No Hooks.



  • true, if the post MIME type is: jpg, jpeg, jpe, gif, png.
  • false in any other case.


wp_attachment_is_image( $post );
Attachment (post) ID or object.
Default: null (global $post)


#1 Check whether an attachment (a post) with ID 37 is an image

$id = 37;
if( wp_attachment_is_image( $id ) )
	echo "Post with ID $id — is an image!";
	echo "Post with ID $id is not an image.";


Since 2.1.0 Introduced.
Since 4.2.0 Modified into wrapper for wp_attachment_is() and allowed WP_Post object to be passed.

Code of wp_attachment_is_image() WP 5.8

function wp_attachment_is_image( $post = null ) {
	return wp_attachment_is( 'image', $post );

From tag: Conditional tags (all)

More from category: Images

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In