From 5ba26e008ca8bacb7963b612c922424e3692c8eb Mon Sep 17 00:00:00 2001 From: selul Date: Wed, 15 Oct 2025 22:52:35 +0300 Subject: [PATCH 1/2] Add smart cropping independent of resize, to accomodate cases when the resize is set from the js lib. fix https://secure.helpscout.net/conversation/3109320210/474190?viewId=2353196 --- composer.lock | 10 +++++----- inc/url_replacer.php | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 595bf547..b8b2f0c5 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/optimole-sdk", - "version": "v1.2.2", + "version": "v1.2.3", "source": { "type": "git", "url": "https://github.com/Codeinwp/optimole-php-sdk.git", - "reference": "567557f1067c934a564154dd292a3f343749b538" + "reference": "901d1f2223df875f8ea65998a76049b0341f8dd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/optimole-php-sdk/zipball/567557f1067c934a564154dd292a3f343749b538", - "reference": "567557f1067c934a564154dd292a3f343749b538", + "url": "https://api.github.com/repos/Codeinwp/optimole-php-sdk/zipball/901d1f2223df875f8ea65998a76049b0341f8dd7", + "reference": "901d1f2223df875f8ea65998a76049b0341f8dd7", "shasum": "" }, "require": { @@ -60,7 +60,7 @@ "issues": "https://github.com/Codeinwp/codeinwp/optimole-php-sdk/issues", "source": "https://github.com/Codeinwp/optimole-php-sdk" }, - "time": "2025-03-28T18:31:54+00:00" + "time": "2025-10-15T19:48:30+00:00" }, { "name": "codeinwp/themeisle-sdk", diff --git a/inc/url_replacer.php b/inc/url_replacer.php index f74ebed3..f6eca2a4 100644 --- a/inc/url_replacer.php +++ b/inc/url_replacer.php @@ -267,6 +267,9 @@ private function normalize_image( $url, $original_url, $args, $is_uploaded = fal if ( ! empty( $args['resize'] ) ) { $this->apply_resize( $image, $args['resize'] ); + } elseif ( $this->settings->is_smart_cropping() ) { + // If smart cropping is enabled and no resize is set, we apply smart focus since the resize can be triggered from the JS library. + $image->smartFocus(); } if ( apply_filters( 'optml_apply_watermark_for', true, $url ) ) { From 7112d8b93191d8082e6a04a79ed8f065111e6613 Mon Sep 17 00:00:00 2001 From: selul Date: Wed, 29 Oct 2025 20:49:07 +0200 Subject: [PATCH 2/2] remove redundant error log --- inc/lazyload_replacer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/lazyload_replacer.php b/inc/lazyload_replacer.php index 37db21b2..15fd4534 100644 --- a/inc/lazyload_replacer.php +++ b/inc/lazyload_replacer.php @@ -524,7 +524,6 @@ public function get_svg_for( $width, $height, $url = null ) { $filepath = WP_CONTENT_DIR . $filepath; if ( is_file( $filepath ) ) { $sizes = getimagesize( $filepath ); - error_log( 'get_svg_for: ' . var_export( $sizes, true ) . ' ' . $url ); wp_cache_add( $key, [ $sizes[0], $sizes[1] ], 'optml_sources', DAY_IN_SECONDS ); } }