Media: unfix admin image cropping calculations.

[58456] introduced some failures to the automated test system that indicate this fix is incomplete.

See #32282.
Props hellofromtonya, audrasjb, andrewserong, kevin940726, oglekler.

Built from https://develop.svn.wordpress.org/trunk@58571


git-svn-id: http://core.svn.wordpress.org/trunk@58019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin
2024-06-25 15:32:16 +00:00
parent 9da0418c41
commit 02ffbdb479
4 changed files with 32 additions and 84 deletions

View File

@@ -735,10 +735,10 @@ function image_edit_apply_changes( $image, $changes ) {
$w = $size['width'];
$h = $size['height'];
$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
$scale = 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
$image->crop( (int) ( $sel->x * $scale ), (int) ( $sel->y * $scale ), (int) ( $sel->w * $scale ), (int) ( $sel->h * $scale ) );
} else {
$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
$scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
}
break;