Languages: English • Italiano • 日本語 (Add your language)
This function determines if a post's attachment is an image. It returns TRUE if the attachment is an image, FALSE if not. The accepted file extensions/mime types are: .jpg, .jpeg, .gif, .png.
<?php wp_attachment_is_image( $post_id ); ?>
To check if post ID 37's attachment is an image:
<?php $id = 37; if ( wp_attachment_is_image( $id ) ) { echo "Post ".$id." is an image!"; } else { echo "Post ".$id." is not an image."; } ?>
Since: 2.1.0
wp_attachment_is_image() is located in wp-includes/post.php
.