Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ffraenz
Copy link

@ffraenz ffraenz commented May 28, 2021

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.

$this->fullsizepath = wp_get_original_image_path( $this->attachment->ID );

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant