WPSEO_Image_Utils::get_image()public staticYoast 1.0

Find the right version of an image based on size.

{} Это метод класса: WPSEO_Image_Utils{}

Хуков нет.

Возвращает

Массив|false. Returns an array with image data on success, false on failure.

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

$result = WPSEO_Image_Utils::get_image( $attachment_id, $size );
$attachment_id(int) (обязательный)
Attachment ID.
$size(строка) (обязательный)
Size name.

Код WPSEO_Image_Utils::get_image() Yoast 19.7.1

public static function get_image( $attachment_id, $size ) {
	$image = false;
	if ( $size === 'full' ) {
		$image = self::get_full_size_image_data( $attachment_id );
	}

	if ( ! $image ) {
		$image = image_get_intermediate_size( $attachment_id, $size );
	}

	if ( ! $image ) {
		return false;
	}

	$image['size'] = $size;

	return self::get_data( $image, $attachment_id );
}