WordPress at a glance
function is not described

WP_Query::is_attachment() WP 3.1.0

Is the query for an existing attachment page?

This is a method of the class: WP_Query

No Hooks.

Return

true/false.

Usage

$WP_Query = new WP_Query();
$var = $WP_Query->is_attachment( $attachment );
$attachment(mixed)
Attachment ID, title, slug, or array of such.
Default: ''

Changelog

Since 3.1.0 Introduced.

Code of WP Query::is attachment: wp-includes/class-wp-query.php WP 5.2.2

<?php
public function is_attachment( $attachment = '' ) {
	if ( ! $this->is_attachment ) {
		return false;
	}

	if ( empty( $attachment ) ) {
		return true;
	}

	$attachment = array_map( 'strval', (array) $attachment );

	$post_obj = $this->get_queried_object();

	if ( in_array( (string) $post_obj->ID, $attachment ) ) {
		return true;
	} elseif ( in_array( $post_obj->post_title, $attachment ) ) {
		return true;
	} elseif ( in_array( $post_obj->post_name, $attachment ) ) {
		return true;
	}
	return false;
}