Yoast\WP\SEO\Helpers\Schema

Image_Helper::add_caption()privateYoast 1.0

Retrieves an image's caption if set, or uses the alt tag if that's set.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->add_caption( $data, $attachment_id, $caption );
$data(массив) (обязательный)
An ImageObject Schema array.
$attachment_id(int) (обязательный)
Attachment ID.
$caption(строка)
The caption string, if there is one.
По умолчанию: ''

Код Image_Helper::add_caption() Yoast 22.4

private function add_caption( $data, $attachment_id, $caption = '' ) {
	if ( $caption !== '' ) {
		$data['caption'] = $caption;

		return $data;
	}

	$caption = $this->image->get_caption( $attachment_id );
	if ( ! empty( $caption ) ) {
		$data['caption'] = $this->html->smart_strip_tags( $caption );

		return $data;
	}

	return $data;
}