Yoast\WP\SEO\Presenters\Open_Graph

Image_Presenter::present()publicYoast 1.0

Returns the image for a post.

Метод класса: Image_Presenter{}

Хуков нет.

Возвращает

Строку. The image tag.

Использование

$Image_Presenter = new Image_Presenter();
$Image_Presenter->present();

Код Image_Presenter::present() Yoast 24.4

public function present() {
	$images = $this->get();

	if ( empty( $images ) ) {
		return '';
	}

	$return = '';
	foreach ( $images as $image_meta ) {
		$image_url = $image_meta['url'];

		if ( \is_attachment() ) {
			global $wp;
			$image_url = \home_url( $wp->request );
		}

		$class = \is_admin_bar_showing() ? ' class="yoast-seo-meta-tag"' : '';

		$return .= '<meta property="og:image" content="' . \esc_url( $image_url, null, 'attribute' ) . '"' . $class . ' />';

		foreach ( static::$image_tags as $key => $value ) {
			if ( empty( $image_meta[ $key ] ) ) {
				continue;
			}

			$return .= \PHP_EOL . "\t" . '<meta property="og:image:' . \esc_attr( $key ) . '" content="' . \esc_attr( $image_meta[ $key ] ) . '"' . $class . ' />';
		}
	}

	return $return;
}