Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
7 changes: 2 additions & 5 deletions src/class-tiny-picture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/class-tiny-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/TinyPictureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function test_adds_both_avif_and_webp()
$this->wp->createImage(1000, '2025/01', 'test.avif');

$input = '<img src="/wp-content/uploads/2025/01/test.png">';
$expected = '<picture><source srcset="/wp-content/uploads/2025/01/test.webp" type="image/webp" /><source srcset="/wp-content/uploads/2025/01/test.avif" type="image/avif" /><img src="/wp-content/uploads/2025/01/test.png"></picture>';
$expected = '<picture><source srcset="/wp-content/uploads/2025/01/test.avif" type="image/avif" /><source srcset="/wp-content/uploads/2025/01/test.webp" type="image/webp" /><img src="/wp-content/uploads/2025/01/test.png"></picture>';
$output = $this->tiny_picture->replace_sources($input);

$this->assertEquals($expected, $output);
Expand Down
2 changes: 1 addition & 1 deletion tiny-compress-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down