WP_Image_Editor_Imagick::save()publicWP 3.5.0

Saves current image to file.

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

Хуков нет.

Возвращает

Массив|WP_Error. Array on success or WP_Error if the file failed to save.

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

$WP_Image_Editor_Imagick = new WP_Image_Editor_Imagick();
$WP_Image_Editor_Imagick->save( $destfilename, $mime_type );
$destfilename(строка)
Destination filename.
По умолчанию: null
$mime_type(строка)
The mime-type.
По умолчанию: null

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

С версии 3.5.0 Введена.
С версии 6.0.0 The $filesize value was added to the returned array.

Код WP_Image_Editor_Imagick::save() WP 6.1.1

public function save( $destfilename = null, $mime_type = null ) {
	$saved = $this->_save( $this->image, $destfilename, $mime_type );

	if ( ! is_wp_error( $saved ) ) {
		$this->file      = $saved['path'];
		$this->mime_type = $saved['mime-type'];

		try {
			$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
		} catch ( Exception $e ) {
			return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
		}
	}

	return $saved;
}