regenerate-thumbnails icon indicating copy to clipboard operation
regenerate-thumbnails copied to clipboard

Fix issue preventing regeneration of PDF attachment thumbnails, refs #94

Open ffraenz opened this issue 3 years ago • 0 comments

When I try to regenerate the thumbnails of a PDF attachment I receive the following error message:

The fullsize image file cannot be found in your uploads directory at . Without it, new thumbnail images can't be generated.

The error message is misleading as there is no issue with the fullsize attachment file.

https://github.com/Automattic/regenerate-thumbnails/blob/5a8b4317f233337a7bb6a50bdc3c3f55b63bdfe2/includes/class-regeneratethumbnails-regenerator.php#L131

The function call above evaluates to false if wp_attachment_is_image($attachment_id) evaluates to false (see why in the WordPress reference). So in particular when dealing with PDF attachments wp_get_original_image_path($attachment_id, ...) always evaluates to false and in turn triggers the regenerate_thumbnails_regenerator_file_not_found error with the message above.

I would suggest to use get_attached_file( $this->attachment->ID ) as the fullsizepath when we are not dealing with an image attachment. This way PDF attachment thumbnails get regenerated as intended.

This issue has already been raised in #94.

ffraenz avatar May 28 '21 10:05 ffraenz