From 6d06951c3a16f5a4c6d3d7efe20ff640730caa27 Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 16 Oct 2025 11:18:04 +0200 Subject: [PATCH 1/3] bug: set order of mimetypes to avif 1st, webp2. reuse protected class variable for checking if source an optimized image --- src/class-tiny-picture.php | 7 ++----- test/unit/TinyPictureTest.php | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/class-tiny-picture.php b/src/class-tiny-picture.php index 0d2de81..c698408 100644 --- a/src/class-tiny-picture.php +++ b/src/class-tiny-picture.php @@ -198,7 +198,7 @@ public function __construct( $html, $base_dir, $domains ) { $this->raw_html = $html; $this->base_dir = $base_dir; $this->allowed_domains = $domains; - $this->valid_mimetypes = array( 'image/webp', 'image/avif' ); + $this->valid_mimetypes = array( 'image/avif', 'image/webp' ); } protected static function get_attribute_value( $element, $name ) { @@ -405,15 +405,12 @@ class Tiny_Picture_Source extends Tiny_Source_Base { public function augment_picture_element() { $modified_sources = array(); - // handle existing sources - $optimized_types = [ 'image/webp', 'image/avif' ]; - foreach ( $this->get_element_by_tag( $this->raw_html, 'source' ) as $source_tag_html ) { $type_attr = self::get_attribute_value( $source_tag_html, 'type' ); $type_attr = null !== $type_attr ? strtolower( trim( $type_attr ) ) : ''; // Skip if already optimized. - if ( '' !== $type_attr && in_array( $type_attr, $optimized_types, true ) ) { + if ( '' !== $type_attr && in_array( $type_attr, $this->valid_mimetypes, true ) ) { continue; } diff --git a/test/unit/TinyPictureTest.php b/test/unit/TinyPictureTest.php index 056c258..c974e07 100644 --- a/test/unit/TinyPictureTest.php +++ b/test/unit/TinyPictureTest.php @@ -199,7 +199,7 @@ public function test_adds_both_avif_and_webp() $this->wp->createImage(1000, '2025/01', 'test.avif'); $input = ''; - $expected = ''; + $expected = ''; $output = $this->tiny_picture->replace_sources($input); $this->assertEquals($expected, $output); From ac7174b975e9009c2a8756d606294e38c556e82a Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 16 Oct 2025 11:20:18 +0200 Subject: [PATCH 2/3] Format --- src/class-tiny-picture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class-tiny-picture.php b/src/class-tiny-picture.php index c698408..fbb05ea 100644 --- a/src/class-tiny-picture.php +++ b/src/class-tiny-picture.php @@ -198,7 +198,7 @@ public function __construct( $html, $base_dir, $domains ) { $this->raw_html = $html; $this->base_dir = $base_dir; $this->allowed_domains = $domains; - $this->valid_mimetypes = array( 'image/avif', 'image/webp' ); + $this->valid_mimetypes = array( 'image/avif', 'image/webp' ); } protected static function get_attribute_value( $element, $name ) { From 1a2b36a41da702f20345d7ffcc58640bc98deb3e Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 16 Oct 2025 11:29:26 +0200 Subject: [PATCH 3/3] v3.6.3 --- readme.txt | 5 ++++- src/class-tiny-plugin.php | 2 +- tiny-compress-images.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index efcd949..9bd6b02 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://tinypng.com/ Tags: compress images, compression, image size, page speed, performance Requires at least: 4.0 Tested up to: 6.8 -Stable tag: 3.6.2 +Stable tag: 3.6.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -174,6 +174,9 @@ A: You can upgrade to a paid account by adding your *Payment details* on your [a A: When the conversion feature is enabled (to convert images to AVIF or WebP), each image will use double the number of credits: one for compression and one for format conversion. == Changelog == += 3.6.3 = +* Changed the source priority for picture elements + = 3.6.2 = * Resolved an issue where the amount of parameters were incorrect when rendering a notice. diff --git a/src/class-tiny-plugin.php b/src/class-tiny-plugin.php index ce6f839..1dd7f73 100644 --- a/src/class-tiny-plugin.php +++ b/src/class-tiny-plugin.php @@ -18,7 +18,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ class Tiny_Plugin extends Tiny_WP_Base { - const VERSION = '3.6.0'; + const VERSION = '3.6.3'; const MEDIA_COLUMN = self::NAME; const DATETIME_FORMAT = 'Y-m-d G:i:s'; diff --git a/tiny-compress-images.php b/tiny-compress-images.php index 55a264a..3b4bb6f 100644 --- a/tiny-compress-images.php +++ b/tiny-compress-images.php @@ -2,7 +2,7 @@ /** * Plugin Name: TinyPNG - JPEG, PNG & WebP image compression * Description: Speed up your website. Optimize your JPEG, PNG, and WebP images automatically with TinyPNG. - * Version: 3.6.2 + * Version: 3.6.3 * Author: TinyPNG * Author URI: https://tinypng.com * Text Domain: tiny-compress-images