Yoast\WP\SEO\Helpers\Schema

Image_Helper::add_image_size()privateYoast 1.0

Adds image's width and height.

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

Хуков нет.

Возвращает

Массив. An imageObject with width and height set if available.

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

// private - только в коде основоного (родительского) класса
$result = $this->add_image_size( $data, $attachment_id );
$data(массив) (обязательный)
An ImageObject Schema array.
$attachment_id(int) (обязательный)
Attachment ID.

Код Image_Helper::add_image_size() Yoast 22.4

private function add_image_size( $data, $attachment_id ) {
	$image_meta = $this->image->get_metadata( $attachment_id );
	if ( empty( $image_meta['width'] ) || empty( $image_meta['height'] ) ) {
		return $data;
	}
	$data['width']  = $image_meta['width'];
	$data['height'] = $image_meta['height'];

	return $data;
}