wp-cli / media-command

Imports files as attachments, regenerates thumbnails, or lists registered image sizes.
MIT License
44 stars 41 forks source link

wp media regenerate for PDF thumbnails #131

Closed MattFCP closed 3 months ago

MattFCP commented 4 years ago

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 commented 10 months ago

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:

https://github.com/wp-cli/media-command/blob/49ef52c657de7ac1e50010ce3f6b0cdc40c02dc7/src/Media_Command.php#L133-L139

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

https://github.com/wp-cli/media-command/blob/49ef52c657de7ac1e50010ce3f6b0cdc40c02dc7/src/Media_Command.php#L925-L945

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