Skip to content

Commit

Permalink
Adapt logic to not break PDFs
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Sep 2, 2022
1 parent 1a91505 commit 56f2c03
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Media_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,17 @@ private function process_regeneration( $id, $skip_delete, $only_missing, $image_
return;
}

// On read error, we might only get the filesize returned and nothing else.
if ( 1 === count( $metadata ) && array_key_exists( 'filesize', $metadata ) ) {
WP_CLI::warning( sprintf( 'Read error while retrieving metadata. (ID %d)', $id ) );
// Note it's possible for no metadata to be generated for PDFs if restricted to a specific image size.
if ( empty( $metadata ) && ! ( $is_pdf && $image_size ) ) {
WP_CLI::warning( sprintf( 'No metadata. (ID %d)', $id ) );
WP_CLI::log( "$progress Couldn't regenerate thumbnails for $att_desc." );
$errors++;
return;
}

// Note it's possible for no metadata to be generated for PDFs if restricted to a specific image size.
if ( empty( $metadata ) && ! ( $is_pdf && $image_size ) ) {
WP_CLI::warning( sprintf( 'No metadata. (ID %d)', $id ) );
// On read error, we might only get the filesize returned and nothing else.
if ( 1 === count( $metadata ) && array_key_exists( 'filesize', $metadata ) && ! ( $is_pdf && $image_size ) ) {
WP_CLI::warning( sprintf( 'Read error while retrieving metadata. (ID %d)', $id ) );
WP_CLI::log( "$progress Couldn't regenerate thumbnails for $att_desc." );
$errors++;
return;
Expand Down

0 comments on commit 56f2c03

Please sign in to comment.