From 1ac9fb70acfeb572a9196689c639a125cf251197 Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 23 Nov 2026 14:32:15 +0100 Subject: [PATCH 1/2] feat: log why compress stops before calling the API Compress returned silently when it skipped an image or found no sizes, so a support log showed only 'compress'. Log the skip reason, the sizes with their paths, and around the backup step. Add backup setting and upload basedir to diagnostics. --- src/class-tiny-diagnostics.php | 3 +++ src/class-tiny-image.php | 31 +++++++++++++++++++++++++++++++ src/class-tiny-plugin.php | 13 ++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/class-tiny-diagnostics.php b/src/class-tiny-diagnostics.php index 6305bfe1..561f9da2 100644 --- a/src/class-tiny-diagnostics.php +++ b/src/class-tiny-diagnostics.php @@ -161,6 +161,7 @@ private static function get_active_plugins() { * @return array Plugin settings */ private function get_tiny_info() { + $upload_dir = wp_upload_dir(); return array( 'version' => Tiny_Plugin::version(), 'status' => $this->settings->get_status(), @@ -170,6 +171,8 @@ private function get_tiny_info() { 'compression_timing' => $this->settings->get_compression_timing(), 'conversion' => $this->settings->get_conversion_options(), 'paying_state' => $this->settings->get_paying_state(), + 'backup_enabled' => $this->settings->get_backup_enabled(), + 'upload_basedir' => $upload_dir['basedir'], ); } diff --git a/src/class-tiny-image.php b/src/class-tiny-image.php index 7ce86c3e..db9279a8 100644 --- a/src/class-tiny-image.php +++ b/src/class-tiny-image.php @@ -259,6 +259,14 @@ public function compress() { ); if ( $this->settings->get_compressor() === null || ! $this->file_type_allowed() ) { + Tiny_Logger::debug( + 'compress skipped', + array( + 'image_id' => $this->id, + 'has_compressor' => null !== $this->settings->get_compressor(), + 'mime_type' => $this->get_mime_type(), + ) + ); return; } @@ -294,6 +302,29 @@ public function compress() { $unprocessed_sizes = $this->filter_image_sizes( 'uncompressed', $active_tinify_sizes ); } + if ( empty( $unprocessed_sizes ) ) { + $sizes = array(); + foreach ( $active_tinify_sizes as $size_name ) { + if ( ! isset( $this->sizes[ $size_name ] ) ) { + continue; + } + $size = $this->sizes[ $size_name ]; + $sizes[ $size_name ] = array( + 'filename' => $size->filename, + 'exists' => $size->exists(), + 'is_duplicate' => $size->is_duplicate(), + 'has_been_compressed' => $size->has_been_compressed(), + ); + } + Tiny_Logger::debug( + 'compress found no sizes to process', + array( + 'image_id' => $this->id, + 'sizes' => $sizes, + ) + ); + } + $compressor = $this->settings->get_compressor(); $convert_to = $this->convert_to(); diff --git a/src/class-tiny-plugin.php b/src/class-tiny-plugin.php index 255717d1..d3cf7f7c 100644 --- a/src/class-tiny-plugin.php +++ b/src/class-tiny-plugin.php @@ -951,9 +951,20 @@ public function backup_original_image( $attachment_id, $wp_metadata = null ) { return false; } + Tiny_Logger::debug( 'create backup', array( 'image_id' => $attachment_id ) ); + $tiny_image = new Tiny_Image( $this->settings, $attachment_id, $wp_metadata ); + $created = $tiny_image->create_backup(); + + Tiny_Logger::debug( + 'create backup finished', + array( + 'image_id' => $attachment_id, + 'created' => $created, + ) + ); - return $tiny_image->create_backup(); + return $created; } /** From 9b4e3cd9632d3575f985aaaafd24d5e384b2ff5f Mon Sep 17 00:00:00 2001 From: tijmen Date: Tue, 24 Nov 2026 09:40:02 +0100 Subject: [PATCH 2/2] fix: log active sizes missing from metadata when compress skips --- src/class-tiny-image.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/class-tiny-image.php b/src/class-tiny-image.php index db9279a8..5c014251 100644 --- a/src/class-tiny-image.php +++ b/src/class-tiny-image.php @@ -306,6 +306,7 @@ public function compress() { $sizes = array(); foreach ( $active_tinify_sizes as $size_name ) { if ( ! isset( $this->sizes[ $size_name ] ) ) { + $sizes[ $size_name ] = 'not in metadata'; continue; } $size = $this->sizes[ $size_name ];