Skip to content

Commit 545e011

Browse files
author
Michiel Verkoijen
committed
Only show errors for image sizes that are selected to be compressed.
1 parent e4f76fc commit 545e011

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/class-tiny-image.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,17 @@ public function get_count($methods, $count_sizes = null) {
254254
}
255255

256256
public function get_latest_error() {
257+
$settings = new Tiny_Settings();
258+
$active_tinify_sizes = $settings->get_active_tinify_sizes();
257259
$error_message = null;
258260
$last_timestamp = null;
259-
foreach ( $this->sizes as $size ) {
260-
if ( isset( $size->meta['error'] ) && isset( $size->meta['message'] ) ) {
261-
if ( $last_timestamp === null || $last_timestamp < $size->meta['timestamp'] ) {
262-
$last_timestamp = $size->meta['timestamp'];
263-
$error_message = $size->meta['message'];
261+
foreach ( $this->sizes as $size_name => $size ) {
262+
if ( in_array( $size_name, $active_tinify_sizes, true ) ) {
263+
if ( isset( $size->meta['error'] ) && isset( $size->meta['message'] ) ) {
264+
if ( $last_timestamp === null || $last_timestamp < $size->meta['timestamp'] ) {
265+
$last_timestamp = $size->meta['timestamp'];
266+
$error_message = $size->meta['message'];
267+
}
264268
}
265269
}
266270
}

0 commit comments

Comments
 (0)