Yoast\WP\SEO\Values
Images::add_image_by_url()
Adds an image based on a given URL.
Метод класса: Images{}
Хуков нет.
Возвращает
number|null
. Returns the found image ID if it exists. Otherwise -1. If the URL is empty we return null.
Использование
$Images = new Images(); $Images->add_image_by_url( $url );
- $url(строка) (обязательный)
- The given URL.
Код Images::add_image_by_url() Images::add image by url Yoast 24.0
public function add_image_by_url( $url ) { if ( empty( $url ) ) { return null; } $image_id = $this->image->get_attachment_by_url( $url ); if ( $image_id ) { $this->add_image_by_id( $image_id ); return $image_id; } $this->add_image( $url ); return -1; }