Yoast\WP\SEO\Helpers\Schema
Image_Helper::generate_from_url
Find an image based on its URL and generate a Schema object for it.
Метод класса: Image_Helper{}
Хуков нет.
Возвращает
Массив. Schema ImageObject array.
Использование
$Image_Helper = new Image_Helper(); $Image_Helper->generate_from_url( $schema_id, $url, $caption, $add_hash, $use_link_table );
- $schema_id(строка) (обязательный)
- The
@idto use for the returned image. - $url(строка) (обязательный)
- The image URL to base our object on.
- $caption(строка)
- An optional caption.
По умолчанию:'' - $add_hash(true|false)
- Whether a hash will be added as a suffix in the @id.
По умолчанию:false - $use_link_table(true|false)
- Whether the SEO Links table will be used to retrieve the id.
По умолчанию:true
Код Image_Helper::generate_from_url() Image Helper::generate from url Yoast 27.6
public function generate_from_url( $schema_id, $url, $caption = '', $add_hash = false, $use_link_table = true ) {
$attachment_id = $this->image->get_attachment_by_url( $url, $use_link_table );
if ( $attachment_id > 0 ) {
return $this->generate_from_attachment_id( $schema_id, $attachment_id, $caption, $add_hash );
}
return $this->simple_image_object( $schema_id, $url, $caption, $add_hash );
}