Yoast\WP\SEO\Generators\Schema

WebPage::add_image()publicYoast 1.0

If we have an image, make it the primary image of the page.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WebPage = new WebPage();
$WebPage->add_image( $data );
$data(массив) (обязательный)
WebPage schema data.

Код WebPage::add_image() Yoast 21.6

public function add_image( $data ) {
	if ( $this->context->has_image ) {
		$data['primaryImageOfPage'] = [ '@id' => $this->context->canonical . Schema_IDs::PRIMARY_IMAGE_HASH ];
		$data['image']              = [ '@id' => $this->context->canonical . Schema_IDs::PRIMARY_IMAGE_HASH ];
		$data['thumbnailUrl']       = $this->context->main_image_url;
	}
	return $data;
}