Yoast\WP\SEO\Helpers\Schema
Image_Helper::add_caption()
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() Image Helper::add caption Yoast 24.3
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; }