WPSEO_Schema_Image{} Yoast 11.1
Запрещена (устарела) с версии 14.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.
Returns schema image data.
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WPSEO_Schema_Image = new WPSEO_Schema_Image(); // use class methods
Методы
- __construct( $schema_id )
- generate_from_attachment_id( $attachment_id, $caption = '' )
- generate_from_url( $url, $caption = '' )
- simple_image_object( $url, $caption = '' )
Список изменений
С версии 11.1 | Введена. |
Устарела с | 14.0 |
Код WPSEO_Schema_Image{} WPSEO Schema Image{} Yoast 15.6.2
class WPSEO_Schema_Image {
/**
* Value to use as the image id.
*
* @var string
*/
private $schema_id;
/**
* WPSEO_Schema_Image constructor.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param string $schema_id The string to use in an image's `@id`.
*/
public function __construct( $schema_id ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image' );
$this->schema_id = $schema_id;
}
/**
* Find an image based on its URL and generate a Schema object for it.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param string $url The image URL to base our object on.
* @param string $caption An optional caption.
*
* @return array Schema ImageObject array.
*/
public function generate_from_url( $url, $caption = '' ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->generate_from_url' );
return YoastSEO()->helpers->schema->image->generate_from_url( $this->schema_id, $url, $caption );
}
/**
* Retrieve data about an image from the database and use it to generate a Schema object.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param int $attachment_id The attachment to retrieve data from.
* @param string $caption The caption string, if there is one.
*
* @return array Schema ImageObject array.
*/
public function generate_from_attachment_id( $attachment_id, $caption = '' ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->generate_from_attachment_id' );
return YoastSEO()->helpers->schema->image->generate_from_attachment_id( $this->schema_id, $attachment_id, $caption );
}
/**
* If we can't find $url in our database, we output a simple ImageObject.
*
* @codeCoverageIgnore
* @deprecated 14.0
*
* @param string $url The image URL.
* @param string $caption A caption, if set.
*
* @return array $data Schema ImageObject array.
*/
public function simple_image_object( $url, $caption = '' ) {
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->simple_image_object' );
return YoastSEO()->helpers->schema->image->simple_image_object( $this->schema_id, $url, $caption );
}
}