WPSEO_Schema_MainImage{} Yoast 11.5
Запрещена (устарела) с версии 14.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.
Returns ImageObject schema data.
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WPSEO_Schema_MainImage = new WPSEO_Schema_MainImage(); // use class methods
Методы
- __construct( $context = null )
- generate_image_schema_from_attachment_id( $image_id )
- generate_image_schema_from_url( $image_id, $image_url )
- get_first_usable_content_image_for_post( $post_id )
Список изменений
С версии 11.5 | Введена. |
Устарела с | 14.0 |
Код WPSEO_Schema_MainImage{} WPSEO Schema MainImage{} Yoast 15.6.2
class WPSEO_Schema_MainImage extends WPSEO_Deprecated_Graph_Piece {
/**
* WPSEO_Schema_WebPage constructor.
*
* @param null $context The context. No longer used but present for BC.
*
* @codeCoverageIgnore
* @deprecated 14.0
*/
public function __construct( $context = null ) {
parent::__construct( Main_Image::class );
}
/**
* Gets the post's first usable content image. Null if none is available.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param int $post_id The post id.
*
* @return string|null The image URL or null if there is no image.
*/
protected function get_first_usable_content_image_for_post( $post_id ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0' );
return WPSEO_Image_Utils::get_first_usable_content_image_for_post( $post_id );
}
/**
* Generates image schema from the attachment id.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param string $image_id The image schema id.
*
* @return array Schema ImageObject array.
*/
protected function generate_image_schema_from_attachment_id( $image_id ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->generate_from_attachment_id' );
return $this->helpers->schema->image->generate_from_attachment_id( $image_id, \get_post_thumbnail_id() );
}
/**
* Generates image schema from the url.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param string $image_id The image schema id.
* @param string $image_url The image URL.
*
* @return array Schema ImageObject array.
*/
protected function generate_image_schema_from_url( $image_id, $image_url ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->generate_from_url' );
return $this->helpers->schema->image->generate_from_url( $image_id, $image_url );
}
}