Image_Helper::generate_from_url()publicYoast 1.0

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 @id to use for the returned image.
$url(строка) (обязательный)
The image URL to base our object on.
An optional caption.
По умолчанию: ''
Whether a hash will be added as a suffix in the @id.
По умолчанию: false
Whether the SEO Links table will be used to retrieve the id.
По умолчанию: true

Код Image_Helper::generate_from_url() Yoast 21.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 );