wp_attachment_is_image() WordPress Function

The wp_attachment_is_image() function is used to check if an attachment is an image. This function can be useful for plugins that need to handle images differently than other attachment types.

wp_attachment_is_image( int|WP_Post $post = null ) #

Determines whether an attachment is an image.


Description

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.


Top ↑

Parameters

$post

(int|WP_Post)(Optional) Attachment ID or object. Default is global $post.

Default value: null


Top ↑

Return

(bool) Whether the attachment is an image.


Top ↑

Source

File: wp-includes/post.php

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


Top ↑

Changelog

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

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More