Yoast\WP\SEO\Context

Meta_Tags_Context::generate_main_image_url()publicYoast 1.0

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() Yoast 22.4

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 ( $this->request_helper->is_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;
}