WP_Image_Editor_GD::_resize()
{} It's a method of the class: WP_Image_Editor_GD{}
No Hooks.
Return
resource|GdImage|WP_Error
.
Usage
// protected - for code of main (parent) or child class $result = $this->_resize( $max_w, $max_h, $crop );
- $max_w(int) (required)
- -
- $max_h(int) (required)
- -
- $crop(true|false|array)
- -
Default: false
Code of WP_Image_Editor_GD::_resize() WP Image Editor GD:: resize WP 6.0
protected function _resize( $max_w, $max_h, $crop = false ) { $dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop ); if ( ! $dims ) { return new WP_Error( 'error_getting_dimensions', __( 'Could not calculate resized image dimensions' ), $this->file ); } list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; $resized = wp_imagecreatetruecolor( $dst_w, $dst_h ); imagecopyresampled( $resized, $this->image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); if ( is_gd_image( $resized ) ) { $this->update_size( $dst_w, $dst_h ); return $resized; } return new WP_Error( 'image_resize_error', __( 'Image resize failed.' ), $this->file ); }