Yoast\WP\SEO\Helpers\Schema
Image_Helper::add_image_size()
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() Image Helper::add image size Yoast 24.6
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; }