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 );
$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

Код Image_Helper::generate_from_url() Yoast 19.11

public function generate_from_url( $schema_id, $url, $caption = '', $add_hash = false ) {
	$attachment_id = $this->image->get_attachment_by_url( $url );
	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 );