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
30 changes: 15 additions & 15 deletions features/media-regenerate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
1/1 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {ATTACHMENT_ID})
1/1 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should not contain:
"""
Expand All @@ -1166,7 +1166,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
1/1 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {ATTACHMENT_ID})
1/1 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -1213,7 +1213,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/2 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID})
/2 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}): no editor available for application/pdf.
"""
And STDOUT should contain:
"""
Expand All @@ -1237,7 +1237,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/2 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID})
/2 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}): no editor available for application/pdf.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -1286,7 +1286,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/1 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID})
/1 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}): no editor available for application/pdf.
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -1371,7 +1371,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/1 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID})
/1 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}): no editor available for application/pdf.
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -1470,7 +1470,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
1/1 Skipped thumbnail regeneration for "My imported BMP attachment" (ID {BMP_ATTACHMENT_ID}).
1/1 Skipped thumbnail regeneration for "My imported BMP attachment" (ID {BMP_ATTACHMENT_ID}): no editor available for image/bmp.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -1529,7 +1529,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
1/1 Skipped thumbnail regeneration for "My imported BMP attachment" (ID {BMP_ATTACHMENT_ID}).
1/1 Skipped thumbnail regeneration for "My imported BMP attachment" (ID {BMP_ATTACHMENT_ID}): no editor available for image/bmp.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -1621,7 +1621,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -1653,11 +1653,11 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}): no editor available for application/pdf.
"""
And STDOUT should contain:
"""
Expand All @@ -1683,11 +1683,11 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported PDF attachment" (ID {PDF_ATTACHMENT_ID}): no editor available for application/pdf.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -1716,7 +1716,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -1765,7 +1765,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}).
/4 Skipped thumbnail regeneration for "My imported SVG attachment" (ID {SVG_ATTACHMENT_ID}): no editor available for image/svg+xml.
"""
And STDOUT should contain:
"""
Expand Down
15 changes: 11 additions & 4 deletions src/Media_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ private function process_regeneration( $id, $skip_delete, $only_missing, $delete
$needs_regeneration = $this->needs_regeneration( $id, $fullsizepath, $is_pdf, $image_sizes, $skip_delete, $skip_it );

if ( $skip_it ) {
WP_CLI::log( "$progress Skipped $thumbnail_desc regeneration for $att_desc." );
WP_CLI::log( "$progress Skipped $thumbnail_desc regeneration for $att_desc: $skip_it" );
++$skips;
return;
}
Expand Down Expand Up @@ -1429,8 +1429,8 @@ private function remove_old_images( $metadata, $fullsizepath, $image_sizes ) {
* @param bool $is_pdf
* @param string[] $image_sizes
* @param bool $skip_delete
* @param bool $skip_it
* @param-out bool $skip_it
* @param string|false $skip_it Reason string if skipping, false otherwise.
* @param-out string|false $skip_it
* @return bool
*/
private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_sizes, $skip_delete, &$skip_it ) {
Expand All @@ -1449,7 +1449,9 @@ private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_siz
if ( ! $is_pdf && is_array( $metadata ) && ! empty( $metadata['sizes'] ) ) {
WP_CLI::warning( sprintf( '%s (ID %d)', $attachment_sizes->get_error_message(), $att_id ) );
}
$skip_it = true;
$mime_type = get_post_mime_type( $att_id );
$skip_it = sprintf( 'no editor available for %s.', $mime_type ? $mime_type : 'this file type' );
WP_CLI::debug( sprintf( 'Skipping attachment %d: %s.', $att_id, $skip_it ), 'media' );
return false;
}

Expand Down Expand Up @@ -1481,6 +1483,7 @@ private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_siz
$filtered_sizes = array_intersect_key( $attachment_sizes, array_flip( $image_sizes ) );

if ( empty( $filtered_sizes ) ) {
WP_CLI::debug( sprintf( 'Not regenerating attachment %d: no requested sizes apply to this attachment.', $att_id ), 'media' );
return false;
}

Expand All @@ -1501,6 +1504,7 @@ private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_siz
}

if ( $this->image_sizes_differ( $attachment_sizes, $metadata['sizes'] ) ) {
WP_CLI::debug( sprintf( 'Regenerating attachment %d: image sizes have changed.', $att_id ), 'media' );
return true;
}

Expand All @@ -1519,9 +1523,12 @@ private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_siz
}

if ( ! file_exists( $intermediate_path ) ) {
WP_CLI::debug( sprintf( 'Regenerating attachment %d: missing thumbnail file "%s".', $att_id, $size_info['file'] ), 'media' );
return true;
}
}

WP_CLI::debug( sprintf( 'Attachment %d: all thumbnails up to date.', $att_id ), 'media' );
return false;
}

Expand Down
Loading