Title: wp_attachment_is_image
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_attachment_is_image( int|WP_Post $post = null ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#wp--skip-link--target)

Determines whether an attachment is an image.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#description)󠁿

For more information on this and similar theme functions, check out the [ Conditional Tags](https://developer.wordpress.org/themes/basics/conditional-tags/)
article in the Theme Developer Handbook.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#parameters)󠁿

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

Attachment ID or object. Default is global $post.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#return)󠁿

 bool Whether the attachment is an image.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/post.php#L7169)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/post.php#L7169-L7171)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_attachment_is()](https://developer.wordpress.org/reference/functions/wp_attachment_is/)`wp-includes/post.php` |

Verifies an attachment is of a given type.

  |

| Used by | Description | 
| [wp_get_original_image_path()](https://developer.wordpress.org/reference/functions/wp_get_original_image_path/)`wp-includes/post.php` |

Retrieves the path to an uploaded image file.

  | 
| [wp_get_original_image_url()](https://developer.wordpress.org/reference/functions/wp_get_original_image_url/)`wp-includes/post.php` |

Retrieves the URL to an original attachment image.

  | 
| [wp_get_missing_image_subsizes()](https://developer.wordpress.org/reference/functions/wp_get_missing_image_subsizes/)`wp-admin/includes/image.php` |

Compare the existing image sub-sizes (as saved in the attachment meta) to the currently registered image sub-sizes, and return the difference.

  | 
| [wp_ajax_media_create_image_subsizes()](https://developer.wordpress.org/reference/functions/wp_ajax_media_create_image_subsizes/)`wp-admin/includes/ajax-actions.php` |

Handles creating missing image sub-sizes for just uploaded images via AJAX.

  | 
| [WP_REST_Attachments_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php` |

Prepares a single attachment output for response.

  | 
| [has_custom_logo()](https://developer.wordpress.org/reference/functions/has_custom_logo/)`wp-includes/general-template.php` |

Determines whether the site has a custom logo.

  | 
| [get_oembed_response_data_rich()](https://developer.wordpress.org/reference/functions/get_oembed_response_data_rich/)`wp-includes/embed.php` |

Filters the oEmbed response data to return an iframe embed code.

  | 
| [edit_form_image_editor()](https://developer.wordpress.org/reference/functions/edit_form_image_editor/)`wp-admin/includes/media.php` |

Displays the image and editor in the post editor

  | 
| [get_media_item()](https://developer.wordpress.org/reference/functions/get_media_item/)`wp-admin/includes/media.php` |

Retrieves HTML form for modifying the image attachment.

  | 
| [get_attachment_icon_src()](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/)`wp-includes/deprecated.php` |

Retrieve icon URL and Path.

  | 
| [image_downsize()](https://developer.wordpress.org/reference/functions/image_downsize/)`wp-includes/media.php` |

Scales an image to fit a particular size (such as ‘thumb’ or ‘medium’).

  |

[Show 6 more](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.2.0](https://developer.wordpress.org/reference/since/4.2.0/) | Modified into wrapper for [wp_attachment_is()](https://developer.wordpress.org/reference/functions/wp_attachment_is/) and allowed [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/) object to be passed. | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/?output_format=md#comment-content-1269)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/#comment-1269)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_attachment_is_image%2F%23comment-1269)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_attachment_is_image%2F%23comment-1269)
 4. **Basic Example**
 5. To check if post ID 37’s attachment is an image:
 6.     ```php
        $id = 37;
        if ( wp_attachment_is_image( $id ) ) {
        	printf( 'Post %d is an image!', $id );
        } else {
        	printf( 'Post %d is not an image.', $id );
        }
        ```
    
 7. _Edited with a contribution from @keraweb_
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_attachment_is_image%2F%3Freplytocom%3D1269%23feedback-editor-1269)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_attachment_is_image%2F)
before being able to contribute a note or feedback.