Yoast\WP\SEO\Helpers

Image_Helper::is_valid_attachment()publicYoast 1.0

Determines whether or not the wanted attachment is considered valid.

Метод класса: Image_Helper{}

Хуков нет.

Возвращает

true|false. Whether or not the attachment is valid.

Использование

$Image_Helper = new Image_Helper();
$Image_Helper->is_valid_attachment( $attachment_id );
$attachment_id(int) (обязательный)
The attachment ID to get the attachment by.

Код Image_Helper::is_valid_attachment() Yoast 22.4

public function is_valid_attachment( $attachment_id ) {
	if ( ! \wp_attachment_is_image( $attachment_id ) ) {
		return false;
	}

	$post_mime_type = \get_post_mime_type( $attachment_id );
	if ( $post_mime_type === false ) {
		return false;
	}

	return $this->is_valid_image_type( $post_mime_type );
}