Yoast\WP\SEO\Context
Meta_Tags_Context::generate_main_image_url()
Retrieves the main image URL. This is the featured image by default.
Метод класса: Meta_Tags_Context{}
Хуков нет.
Возвращает
Строку|null
. The main image URL.
Использование
$Meta_Tags_Context = new Meta_Tags_Context(); $Meta_Tags_Context->generate_main_image_url();
Код Meta_Tags_Context::generate_main_image_url() Meta Tags Context::generate main image url Yoast 24.7
public function generate_main_image_url() { if ( $this->main_image_id !== null ) { return $this->image->get_attachment_image_url( $this->main_image_id, 'full' ); } if ( \wp_is_serving_rest_request() ) { return $this->get_main_image_url_for_rest_request(); } if ( ! \is_singular() ) { return null; } $url = $this->image->get_post_content_image( $this->id ); if ( $url === '' ) { return null; } return $url; }