WPSEO_Image_Utils::get_variations()public staticYoast 1.0

Returns the different image variations for consideration.

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

Хуков нет.

Возвращает

Массив. The different variations possible for this attachment ID.

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

$result = WPSEO_Image_Utils::get_variations( $attachment_id );
$attachment_id(int) (обязательный)
The attachment to return the variations for.

Код WPSEO_Image_Utils::get_variations() Yoast 22.4

public static function get_variations( $attachment_id ) {
	$variations = [];

	foreach ( self::get_sizes() as $size ) {
		$variation = self::get_image( $attachment_id, $size );

		// The get_image function returns false if the size doesn't exist for this attachment.
		if ( $variation ) {
			$variations[] = $variation;
		}
	}

	return $variations;
}