diff --git a/assets/src/dashboard/parts/connected/settings/Compression.js b/assets/src/dashboard/parts/connected/settings/Compression.js index ed392d4e..7ed554c8 100644 --- a/assets/src/dashboard/parts/connected/settings/Compression.js +++ b/assets/src/dashboard/parts/connected/settings/Compression.js @@ -55,7 +55,6 @@ const Compression = ({ const isNetworkOptimizationEnabled = 'disabled' !== settings[ 'network_optimization' ]; const isCDNEnabled = 'disabled' !== settings.cdn; - const isAVIFEnabled = 'disabled' !== settings.avif; const isStripMetadataEnabled = 'disabled' !== settings[ 'strip_metadata' ]; const isAutoQualityEnabled = 'disabled' !== settings.autoquality; const isBestFormatEnabled = 'disabled' !== settings[ 'best_format' ]; @@ -140,10 +139,10 @@ const Compression = ({ setCanSave( true ); const data = { ...settings }; if ( 'speed_optimized' === value ) { - data[ 'best_format' ] = 'disabled'; + data[ 'best_format' ] = 'enabled'; data[ 'retina_images' ] = 'disabled'; data[ 'network_optimization' ] = 'enabled'; - data.avif = 'mauto'; + data.avif = 'enabled'; data.autoquality = 'enabled'; data[ 'strip_metadata' ] = 'enabled'; } @@ -160,7 +159,6 @@ const Compression = ({ data[ 'best_format' ] = ( customSettings.best_format ?? isBestFormatEnabled ) ? 'enabled' : 'disabled'; data[ 'retina_images' ] = ( customSettings.retina_images ?? isRetinaEnabled ) ? 'enabled' : 'disabled'; data[ 'network_optimization' ] = ( customSettings.network_optimization ?? isNetworkOptimizationEnabled ) ? 'enabled' : 'disabled'; - data.avif = ( customSettings.avif ?? isAVIFEnabled ) ? 'enabled' : 'disabled'; data.autoquality = ( customSettings.autoquality ?? isAutoQualityEnabled ) ? 'enabled' : 'disabled'; data[ 'strip_metadata' ] = ( customSettings.strip_metadata ?? isStripMetadataEnabled ) ? 'enabled' : 'disabled'; } @@ -280,21 +278,6 @@ const Compression = ({
-

} - checked={ isAVIFEnabled } - disabled={ isLoading } - className={ classnames( - { - 'is-disabled': isLoading - } - ) } - onChange={ value => updateOption( 'avif', value ) } - /> - -


-

} diff --git a/inc/admin.php b/inc/admin.php index a623a150..c1a26e62 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -391,9 +391,7 @@ public function update_default_settings() { $this->settings->update( 'limit_dimensions', 'enabled' ); $this->settings->update( 'lazyload', 'enabled' ); - $this->settings->update( 'best_format', 'disabled' ); $this->settings->update( 'skip_lazyload_images', '2' ); - $this->settings->update( 'avif', 'disabled' ); $this->settings->update( 'compression_mode', 'speed_optimized' ); update_option( self::NEW_USER_DEFAULTS_UPDATED, 'yes' ); @@ -1720,7 +1718,7 @@ private function get_dashboard_strings() { 'best_format_title' => __( 'Automatic Best Image Format Selection', 'optimole-wp' ), 'best_format_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ - __( 'When enabled, Optimole picks the ideal format for your images, balancing quality and speed. It tests different formats, like AVIF and WebP, ensuring images look good and load quickly. %1$sLearn more%2$s.', 'optimole-wp' ), + __( 'When enabled, Optimole chooses the best format for your images, balancing quality with speed. It tries options like AVIF and WebP to keep visuals sharp and pages fast, though uncached images may take a bit longer to process. %1$sLearn more%2$s.', 'optimole-wp' ), '', '' ), @@ -1826,7 +1824,7 @@ private function get_dashboard_strings() { 'enable_resize_smart_title' => __( 'Smart Cropping', 'optimole-wp' ), 'enable_retina_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ - __( 'Enable this feature to optimize your images for Retina displays. Retina-ready images are optimized to look sharp on screens with higher pixel density, offering viewers enhanced visual quality. %1$sLearn more%2$s', 'optimole-wp' ), + __( 'Optimizes images for Retina (high-DPI) screens for sharper results. Always enabled for images under 150px wide. %1$sLearn more%2$s', 'optimole-wp' ), '', '' ), diff --git a/inc/settings.php b/inc/settings.php index 68f219a5..98d2b6ad 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -86,7 +86,7 @@ class Optml_Settings { 'img_to_video' => 'disabled', 'css_minify' => 'enabled', 'js_minify' => 'disabled', - 'avif' => 'enabled', + 'avif' => 'enabled', // legacy setting, is no longer used in the UI 'autoquality' => 'enabled', 'native_lazyload' => 'disabled', 'offload_media' => 'disabled', diff --git a/inc/url_replacer.php b/inc/url_replacer.php index 81cbaf20..a0f14a6f 100644 --- a/inc/url_replacer.php +++ b/inc/url_replacer.php @@ -226,6 +226,22 @@ private function normalize_image( $url, $original_url, $args, $is_uploaded = fal $args['resize']['gravity'] = GravityProperty::SMART; } + $is_retina_enabled = $this->settings->get( 'retina_images' ) !== 'disabled'; + if ( ! $is_retina_enabled ) { + $max_dimension = max( $args['width'], $args['height'] ); + $should_apply_dpr = false; + + if ( $max_dimension > 0 && $max_dimension < 150 ) { + $should_apply_dpr = true; + } + + $should_apply_dpr = apply_filters( 'optml_should_apply_dpr', $should_apply_dpr, $args, $url ); + + if ( $should_apply_dpr && ! isset( $args['dpr'] ) ) { + $args['dpr'] = 2; + } + } + $args = apply_filters( 'optml_image_args', $args, $original_url ); $image = Optimole::image( apply_filters( 'optml_processed_url', $url ), self::get_active_cache_booster( $url, $this->active_cache_buster ) ); diff --git a/tests/test-lazyload.php b/tests/test-lazyload.php index d2ad301b..d10ce64b 100644 --- a/tests/test-lazyload.php +++ b/tests/test-lazyload.php @@ -235,7 +235,7 @@ public function test_lazy_load_preserve_image_size() { $this->assertNotEquals( $replaced_content, $html ); $this->assertStringNotContainsString( 'q:eco/rt:fill/g:ce', $replaced_content ); $this->assertStringContainsString( '/rt:fill/g:ce', $replaced_content ); - $this->assertStringContainsString( '/w:96/h:96/q:eco/ig:avif/http://example.org/', $replaced_content ); + $this->assertStringContainsString( '/w:96/h:96/q:eco/f:best/dpr:2/http://example.org/', $replaced_content ); } @@ -248,7 +248,7 @@ public function test_width_100() { $replaced_content = Optml_Manager::instance()->replace_content( $content ); - $this->assertEquals( '', $replaced_content ); + $this->assertEquals( '', $replaced_content ); } public function test_check_with_no_script() { @@ -542,7 +542,7 @@ public function test_generic_placeholder() { public function test_dam_lazyloading() { $replaced_content = Optml_Manager::instance()->process_images_from_content( self::DAM_IMG_TAG ); - $this->assertStringContainsString( 'data-opt-src="https://cloudUrlTest.test/w:100/h:200/rt:fill/g:ce/ig:avif/q:mauto/id:b1b12ee03bf3945d9d9bb963ce79cd4f/https://test-site.test/9.jpg"', $replaced_content ); + $this->assertStringContainsString( 'data-opt-src="https://cloudUrlTest.test/w:100/h:200/rt:fill/g:ce/f:best/q:mauto/id:b1b12ee03bf3945d9d9bb963ce79cd4f/https://test-site.test/9.jpg"', $replaced_content ); } public function test_dam_lazyloading_no_wh_attributes() { add_filter('optml_lazyload_images_skip','__return_zero'); diff --git a/tests/test-replacer.php b/tests/test-replacer.php index c6fbb1a8..6f482db3 100644 --- a/tests/test-replacer.php +++ b/tests/test-replacer.php @@ -346,7 +346,7 @@ public function test_assets_url() { $this->assertStringContainsString( 'https://test123.i.optimole.com/cb:eFRn.20eff/f:js/q:mauto/m:0/http://example.org/wp-content/plugins/divi-bars/assets/js/snap.svg-min.js', $replaced_content ); $this->assertStringContainsString( 'https://test123.i.optimole.com/cb:eFRn.20eff/f:css/q:mauto/m:1/http://example.org/wp-includes/js/hoverintent-js.min.png-random.css', $replaced_content ); $this->assertStringContainsString( 'https://test123.i.optimole.com/cb:eFRn.20eff/f:js/q:mauto/m:0/http://example.org/wp-includes/js/assets/whatever.jpg.png.css.js', $replaced_content ); - $this->assertStringContainsString( 'https://test123.i.optimole.com/cb:eFRn.20eff/w:auto/h:auto/q:mauto/ig:avif/https://example.org/wp-includes/js/assets/whatever.jpg.jpg', $replaced_content ); + $this->assertStringContainsString( 'https://test123.i.optimole.com/cb:eFRn.20eff/w:auto/h:auto/q:mauto/f:best/https://example.org/wp-includes/js/assets/whatever.jpg.jpg', $replaced_content ); $settings = new Optml_Settings(); $settings->update( 'css_minify', 'disabled' );