WP_Image_Editor::resize( int|null $max_w, int|null $max_h, bool $crop = false )

Resizes current image.

Description

At minimum, either a height or width must be provided. If one of the two is set to null, the resize will maintain aspect ratio according to the provided dimension.

Parameters

$max_w

(int|null) (Required) Image width.

$max_h

(int|null) (Required) Image height.

$crop

(bool) (Optional)

Default value: false

Return

(true|WP_Error)

More Information

Crop value:
1. If false (default), images will not be cropped.
2. If an array in the form of array( x_crop_position, y_crop_position ):
– x_crop_position accepts ‘left’ ‘center’, or ‘right’.
– y_crop_position accepts ‘top’, ‘center’, or ‘bottom’.
Images will be cropped to the specified dimensions within the defined crop area.
3. If true, images will be cropped to the specified dimensions using center p

Source

File: wp-includes/class-wp-image-editor.php

abstract public function resize( $max_w, $max_h, $crop = false );

Changelog

Version Description
3.5.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_image_editor/resize