WordPress plugin intelligence profile

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.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 4.6
Current version2.2.0
WordPress coverageTested up to WordPress 4.6
Minimum stackWP — · PHP —
Directory statusactive
Last directory update24 Oct 201610y ago
Active installations1K+Adoption metric — not a quality score
WordPress.org rating4.6 / 5 from 9 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records PDF Thumbnails version 2.2.0 as active, updated 10y ago and tested up to WordPress 4.6.

Overview

About this plugin

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.

Shortcodes

It is possible to display a thumbnail linking to an uploaded PDF using the [pdf_thumbnails_link]

shortcode. The following attributes are supported:

  • id – Attachment ID (required)
  • size – Thumbnail size (optional)
  • title – Anchor title attribute (optional)
  • target – Anchor target attribute (optional)
  • download – Anchor download attribute (optional)

Example 1: Display link to PDF with ID = 172 using default thumbnail size

[pdf_thumbnails_link id="172"]

Example 2: Display link to PDF with ID = 172 using thumbnail size (default 150×150)

[pdf_thumbnails_link id="172" size="thumbnail"]

Thanks to mirgcire for providing the first

version of the [pdf_thumbnails_link] shortcode.

Developer 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 1: 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);

It is possible to modify generated thumbnail links using the pdf_thumbnails_link_shortcode

filter. The following attributes are available:

  • $html – Generated HTML code to be displayed
  • $attachmentId – Sanitized ID of the PDF attachment
  • $size – Sanitized thumbnail size
  • $atts – Shortcode attributes (not sanitized)
  • $content – Shortcode content (not sanitized)

Example 2: Wrap thumbnail link in figure and append caption

add_filter('pdf_thumbnails_link_shortcode', function ($html, $attachmentId, $size, $atts, $content) { return "<figure>$html <caption>Click to open image $attachmentId</caption></figure>"; }, 10, 5);

TODO

Add generated image to media browser after upload.

Outline of an implementation based on the javascript media API:

on('add', function (attachment) {

== 'pdf') { return; }

then(function (data) {

add(generated attachment) });

}); });

Filter: ajax_query_attachments_args

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • generator
  • pdf
  • thumbnail
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 4.6

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 4.6.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to4.6
Minimum requirementsWordPress not listed · PHP not listed
Update activity24 Oct 201610y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.