WordPress.org

Plugin Directory

PDF Thumbnails

This plugin generates a thumbnail everytime you upload a PDF attachment. Generated thumbnail is an image of the first page in uploaded document.

This plugin hooks into the media manager and generates a thumbnail everytime a PDF is uploaded. Generated thumbnail is an image of the first page in the uploaded document and is named PDFNAME-thumbnail, where PDFNAME is replaced by uploaded document filename.

Generated thumbnails are equivalent to featured images so that common thumbnail functions like get_post_thumbnail_id() can be used for PDF attachments. See Post Thumbnails for information on how you can use thumbnails efficiently.

Integration with the javascript media API is not yet implemented, therefore, you may need to reload the page before you can see generated thumbnail after an upload.

API

In most cases it should be sufficient to use built-in thumbnail functions from the WordPress API (get_post_thumbnail and similar).If you need to modify the way thumbnails are generated, you can override image generation with the pdf_thumbnails_generate_image_blob filter.

Example: Increase resolution for all generated PDF thumbnails

// $blob is the current image blob (defaults to null, can be used for chaining)
// $filename is the PDF filename
add_action('pdf_thumbnails_generate_image_blob', function ($blob, $filename) {
    $imagick = new Imagick();
    $imagick->setResolution(200,200);
    $imagick->readImage($filename);
    $imagick->setIteratorIndex(0);
    $imagick->setImageFormat('jpg');
    return $imagick->getImageBlob();
}, 10, 2);

Compatible up to: 4.3.3
Last Updated: 4 months ago
Active Installs: 1,000+

Ratings

5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1 100,1,1 0,1,0
100,1,1 100,1,1
100,1,1 100,1,1
0,1,0
100,1,1 100,1,1
100,2,2
100,1,1 100,1,1