From 49ccd3555630fdbe91b0fc3afe2252f8cb35b0ec Mon Sep 17 00:00:00 2001 From: Erik van der Bas Date: Mon, 13 May 2024 22:19:16 +0200 Subject: [PATCH 1/2] fix: fix regression where crops with the default crop setting would squeeze the image inside dimensions instead of cropping. --- src/Image/Operation/Resize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Image/Operation/Resize.php b/src/Image/Operation/Resize.php index e206467d3..60783bf6b 100644 --- a/src/Image/Operation/Resize.php +++ b/src/Image/Operation/Resize.php @@ -113,7 +113,7 @@ protected function get_target_sizes(WP_Image_Editor $image) $w = \round($h * $src_ratio); } - if (!$crop || $crop === 'default') { + if (!$crop) { return [ 'x' => 0, 'y' => 0, From cf895a34600dae6edb9020ec236137fe2de9baac Mon Sep 17 00:00:00 2001 From: Erik van der Bas Date: Tue, 14 May 2024 12:11:02 +0200 Subject: [PATCH 2/2] fix: possible solution for precision warning --- src/Image/Operation/Resize.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Image/Operation/Resize.php b/src/Image/Operation/Resize.php index 60783bf6b..7cc649c7d 100644 --- a/src/Image/Operation/Resize.php +++ b/src/Image/Operation/Resize.php @@ -210,12 +210,12 @@ public function run($load_filename, $save_filename) $crop = $this->get_target_sizes($image); $image->crop( - $crop['x'], - $crop['y'], - $crop['src_w'], - $crop['src_h'], - $crop['target_w'], - $crop['target_h'] + (int) $crop['x'], + (int) $crop['y'], + (int) $crop['src_w'], + (int) $crop['src_h'], + (int) $crop['target_w'], + (int) $crop['target_h'] ); $quality = \apply_filters('wp_editor_set_quality', 82, 'image/jpeg'); $image->set_quality($quality);