Yoast\WP\SEO\Generators\Schema

Person::add_image()protectedYoast 1.0

Returns an ImageObject for the persons avatar.

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

Хуков нет.

Возвращает

Массив<Строку|Строку[]>. The Person schema.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->add_image( $data, $user_data, $add_hash );
$data(array<string|string[]>) (обязательный)
The Person schema.
$user_data(WP_User) (обязательный)
User data.
$add_hash(true|false)
Wether or not the person's image url hash should be added to the image id.
По умолчанию: false

Код Person::add_image() Yoast 22.4

protected function add_image( $data, $user_data, $add_hash = false ) {
	$schema_id = $this->context->site_url . Schema_IDs::PERSON_LOGO_HASH;

	$data = $this->set_image_from_options( $data, $schema_id, $add_hash, $user_data );
	if ( ! isset( $data['image'] ) ) {
		$data = $this->set_image_from_avatar( $data, $user_data, $schema_id, $add_hash );
	}

	if ( \is_array( $this->type ) && \in_array( 'Organization', $this->type, true ) ) {
		$data_logo    = ( $data['image']['@id'] ?? $schema_id );
		$data['logo'] = [ '@id' => $data_logo ];
	}

	return $data;
}