From 8a4deae8f85fed2a456b4583ef48f17c3dca9f5e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 1 Jul 2024 20:45:15 +0000 Subject: [PATCH] REST API: Correct image cropping tools in the block editor. As of [58457], the width and height cropping values are cast to an integer before the comparison to see if the target width and height differ from the original width and height. Since they are now integers, it exposes a bug where the `&&` of the `if` conditional meant that if you were only cropping in one dimension, the check wouldn't pass, and cropping would not occur. In the block editor, the cropping tools are aspect ratio based, so one of the dimensions will always match that of the source image. Therefore, now that the values are cast as integers, the condition that allows a cropping to occur needs to be updated. If either width or height is different from the source image, then a crop should be allowed. Follow-up to [50124], [58457]. Props andrewserong, jrf, kevin940726. Fixes #61514. See #59782. Built from https://develop.svn.wordpress.org/trunk@58612 git-svn-id: http://core.svn.wordpress.org/trunk@58045 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../rest-api/endpoints/class-wp-rest-attachments-controller.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 370025d927..cbc62b49ea 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -626,7 +626,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $width = (int) round( ( $size['width'] * $args['width'] ) / 100.0 ); $height = (int) round( ( $size['height'] * $args['height'] ) / 100.0 ); - if ( $size['width'] !== $width && $size['height'] !== $height ) { + if ( $size['width'] !== $width || $size['height'] !== $height ) { $result = $image_editor->crop( $crop_x, $crop_y, $width, $height ); if ( is_wp_error( $result ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 067422cda1..d8c6e1a805 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58601'; +$wp_version = '6.7-alpha-58612'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.