You are correct, thumbnails is generated by hooking into the wp_generate_attachment_metadata
hook, which triggers when you upload a new file.
Unfortunately, the regenerate thumbnails plugin only loops through images, so it will not trigger thumbnail generation for PDFs. It would be useful to support the regenerate thumbnails plugin. I will check with the author to see if we can figure something out. However, I reckon that will take some time.
For now, you can do it manually with the following code snippet:
add_action('admin_init', function () {
if (!isset($_GET['regenerate_pdf_thumbnails'])) {
return;
}
$chunk_size = empty($_GET['regenerate_pdf_thumbnails_chunk_size']) ? -1
: $_GET['regenerate_pdf_thumbnails_chunk_size'];
// Get all attachments
$posts = get_posts(array(
'post_type' => 'attachment',
'post_status' => 'any',
'posts_per_page' => $chunk_size,
'fields' => 'ids',
'paged' => (int) $_GET['regenerate_pdf_thumbnails'],
'meta_key' => 'PdfThumbnailsPlugin',
'meta_compare' => 'NOT EXISTS'
));
// Regenerate metadata (incl. thumbnails and pdf thumnails)
foreach ($posts as $id) {
$file = get_attached_file($id);
$meta = wp_generate_attachment_metadata($id, $file);
update_post_meta($id, $meta);
}
});
With that you can use https://YOURSITE?regenerate_pdf_thumbnails
to trigger the generation. To avoid PHP running for too long, and cancelling the operation, you can use:
Regenerate attachments 1-5:
https://YOURSITE/wp-admin/upload.php?regenerate_pdf_thumbnails=1®enerate_pdf_thumbnails_chunk_size=5
Regenerate attachments 6-10:
https://YOURSITE/wp-admin/upload.php?regenerate_pdf_thumbnails=1®enerate_pdf_thumbnails_chunk_size=5
And so on.