WP_Widget_Media::is_attachment_with_mime_type

Advertisement

Summery Summery

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

Syntax Syntax

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

Parameters Parameters

$attachment

(int|WP_Post) (Required) Attachment post ID or object.

$mime_type

(string) (Required) MIME type.

Return Return

(bool) Is matching MIME type.

Source Source

File: wp-includes/widgets/class-wp-widget-media.php

	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 );
	}

Advertisement

Changelog Changelog

Changelog
Version Description
4.8.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.