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

wp media regenerate for PDF thumbnails #131

Closed
MattFCP opened this issue May 19, 2020 · 1 comment
Closed

wp media regenerate for PDF thumbnails #131

MattFCP opened this issue May 19, 2020 · 1 comment

Comments

@MattFCP
Copy link

MattFCP commented May 19, 2020

Feature Request

I haven't been able to find a way to regenerate PDF thumbnails. Reason I'm trying to is there must have been a bug in WordPress 5 that stopped this from working. It seems to be working now, but I have 50 or so pdfs that I need to regenerate thumbnails for. I tried WP-CLI command "wp media regenerate IMAGEID" and for PDFs it returns the error "No images found". While it works for regular images, it would be nice for this to work for PDFs as well.

Thanks,
Matt

@danielbachhuber
Copy link
Member

Thanks for the report, @MattFCP !

Were you able to track this issue down? Can you share more steps to reproduce? Did your 50 original PDFs have thumbnails, or were they missing entirely?

The "No images found" error happens here:

$images = $this->get_images( $args, $additional_mime_types );
$count = $images->post_count;
if ( ! $count ) {
WP_CLI::warning( 'No images found.' );
return;
}

WP-CLI is simply querying post objects from the database, though:

/**
* Get images from the installation.
*
* @param array $args The query arguments to use. Optional.
* @param array $additional_mime_types The additional mime types to search for. Optional.
*
* @return WP_Query The query result.
*/
private function get_images( $args = array(), $additional_mime_types = array() ) {
$mime_types = array_merge( array( 'image' ), $additional_mime_types );
$query_args = array(
'post_type' => 'attachment',
'post__in' => $args,
'post_mime_type' => $mime_types,
'post_status' => 'any',
'posts_per_page' => -1,
);
return new WP_Query( $query_args );
}

The error would imply that the post objects don't exist.

@danielbachhuber danielbachhuber closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment