WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Image_Editor_Imagick::make_subsize() public WP 5.3.0

Create an image sub-size and return the image meta data value for it.

Это метод класса: WP_Image_Editor_Imagick{}

Хуков нет.

Возвращает

Массив/WP_Error. The image data array for inclusion in the sizes array in the image meta, WP_Error object on error.

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

$WP_Image_Editor_Imagick = new WP_Image_Editor_Imagick();
$WP_Image_Editor_Imagick->make_subsize( $size_data );
$size_data(массив) (обязательный)

Array of size data.

  • width(число)
    The maximum width in pixels.

  • height(число)
    The maximum height in pixels.

  • crop(true/false)
    Whether to crop the image to exact dimensions.

Список изменений

С версии 5.3.0 Введена.

Код WP_Image_Editor_Imagick::make_subsize() WP 5.5.1

wp-includes/class-wp-image-editor-imagick.php
<?php
public function make_subsize( $size_data ) {
	if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
		return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) );
	}

	$orig_size  = $this->size;
	$orig_image = $this->image->getImage();

	if ( ! isset( $size_data['width'] ) ) {
		$size_data['width'] = null;
	}

	if ( ! isset( $size_data['height'] ) ) {
		$size_data['height'] = null;
	}

	if ( ! isset( $size_data['crop'] ) ) {
		$size_data['crop'] = false;
	}

	$resized = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );

	if ( is_wp_error( $resized ) ) {
		$saved = $resized;
	} else {
		$saved = $this->_save( $this->image );

		$this->image->clear();
		$this->image->destroy();
		$this->image = null;
	}

	$this->size  = $orig_size;
	$this->image = $orig_image;

	if ( ! is_wp_error( $saved ) ) {
		unset( $saved['path'] );
	}

	return $saved;
}