WP_Widget_Media::is_attachment_with_mime_type( int|WP_Post $attachment, string $mime_type ): bool

In this article

Determine if the supplied attachment is for a valid attachment post with the specified MIME type.

Parameters

$attachmentint|WP_Postrequired
Attachment post ID or object.
$mime_typestringrequired
MIME type.

Return

bool Is matching MIME type.

Source

public function is_attachment_with_mime_type( $attachment, $mime_type ) {
	if ( empty( $attachment ) ) {
		return false;
	}
	$attachment = get_post( $attachment );
	if ( ! $attachment ) {
		return false;
	}
	if ( 'attachment' !== $attachment->post_type ) {
		return false;
	}
	return wp_attachment_is( $mime_type, $attachment );
}

Changelog

VersionDescription
4.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.