wp_attachment_is_image( int|WP_Post $post = null )
Determines whether an attachment is an image.
Description Description
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Parameters Parameters
- $post
-
(int|WP_Post) (Optional) Attachment ID or object. Default is global $post.
Default value: null
Return Return
(bool) Whether the attachment is an image.
Source Source
File: wp-includes/post.php
function wp_attachment_is_image( $post = null ) { return wp_attachment_is( 'image', $post ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.2.0 | Modified into wrapper for wp_attachment_is() and allowed WP_Post object to be passed. |
2.1.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
To check if post ID 37’s attachment is an image: