Title: PDF Thumbnail Generator
Author: kubiq
Published: <strong>8. juli, 2022</strong>
Last modified: 1. december, 2025

---

Søg plugins

![](https://ps.w.org/pdf-thumbnail-generator/assets/banner-772x250.png?rev=2753908)

![](https://ps.w.org/pdf-thumbnail-generator/assets/icon.svg?rev=2753908)

# PDF Thumbnail Generator

 Af [kubiq](https://profiles.wordpress.org/kubiq/)

[Download](https://downloads.wordpress.org/plugin/pdf-thumbnail-generator.1.5.zip)

 * [Detaljer](https://da.wordpress.org/plugins/pdf-thumbnail-generator/#description)
 * [Vurderinger](https://da.wordpress.org/plugins/pdf-thumbnail-generator/#reviews)
 *  [Installation](https://da.wordpress.org/plugins/pdf-thumbnail-generator/#installation)
 * [Udvikling](https://da.wordpress.org/plugins/pdf-thumbnail-generator/#developers)

 [Support](https://wordpress.org/support/plugin/pdf-thumbnail-generator/)

## Beskrivelse

Generates thumbnail for PDF file automatically after file is uploaded to the Media
library.

You can also generate thumbnails for old PDF files that are already in the Media
library – you can generate missing thumbnails or regenerate all thumbnails.

**Imagick library must be installed on your server, otherwise this plugin will not
work**

 * automated test after plugin activation to make sure it will work on your server
 * works with all types of WordPress installations: domain, subdomain, subdirectory,
   multisite/network
 * works on Apache and NGiNX
 * automatically generate thumbnail for new uploaded PDFs
 * (re)generate thumbnails for existing PDFs in Media library
 * set maximum width of PDF thumbnail
 * set maximum height of PDF thumbnail
 * set image quality of PDF thumbnail
 * set image file type of PDF thumbnail

### Shortcodes

### pdf_thumbnail

Maybe you want to display PDF thumbnail by using a shortcode

    ```
    [pdf_thumbnail id="123"]
    ```

### pdf_thumbnail_url

Maybe you want to display PDF thumbnail url by using a shortcode

    ```
    [pdf_thumbnail_url id="123"]
    ```

### pdf_clickable_thumbnail

Maybe you want to display clickable PDF thumbnail that will open PDF in new tab

    ```
    [pdf_clickable_thumbnail id="123"]
    ```

 

### Functions

### get_pdf_thumbnail_url

If you want to return PDF thumbnail URL you can use

    ```
    get_pdf_thumbnail_url( $pdf_id )
    ```

it works similar to `wp_get_attachment_url` and it will return something like

    ```
    https://site.com/wp-content/uploads/2022/01/example.pdf.png
    ```

### get_pdf_thumbnail_path

If you want to return PDF thumbnail URL you can use

    ```
    get_pdf_thumbnail_path( $pdf_id )
    ```

it works similar to `get_attached_file` and it will return something like

    ```
    /www/site.com/wp-content/uploads/2022/01/example.pdf.png
    ```

### get_pdf_thumbnail_image_src

If you want to return PDF thumbnail url, width and height you can use

    ```
    get_pdf_thumbnail_image_src( $pdf_id )
    ```

it works similar to `wp_get_attachment_image_src` and it will return something like

    ```
    [
        0 => 'https://site.com/wp-content/uploads/2022/01/example.pdf.png',
        1 => 600,
        2 => 800
    ]
    ```

### get_pdf_thumbnail_image

If you want to return PDF thumbnail image tag you can use

    ```
    get_pdf_thumbnail_image( $pdf_id )
    ```

it works similar to `wp_get_attachment_image` and it will return something like

    ```
    <img src="https://site.com/wp-content/uploads/2022/01/example.pdf.png" width="600" height="800" alt="example" loading="lazy">
    ```

 

### Hooks

### pdf_thumbnail_max_width

Maybe you want to change global PDF thumbnail max_width for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_max_width', function( $max_width, $pdf_id ){
        if( $pdf_id == 123 ){
            return 1024;
        }
        return $max_width;
    }, 10, 2 );
    ```

### pdf_thumbnail_max_height

Maybe you want to change global PDF thumbnail max_width for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_max_height', function( $max_height, $pdf_id ){
        if( $pdf_id == 123 ){
            return 768;
        }
        return $max_height;
    }, 10, 2 );
    ```

### pdf_thumbnail_quality

Maybe you want to change global PDF thumbnail quality for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_quality', function( $quality, $pdf_id ){
        if( $pdf_id == 123 ){
            return 100;
        }
        return $quality;
    }, 10, 2 );
    ```

### pdf_thumbnail_type

Maybe you want to change global PDF thumbnail file type for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_type', function( $type, $pdf_id ){
        if( $pdf_id == 123 ){
            return 'png'; // or 'jpg'
        }
        return $type;
    }, 10, 2 );
    ```

### pdf_thumbnail_bgcolor

Maybe you want to change default PDF thumbnail background for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_bgcolor', function( $bgcolor, $pdf_id ){
        if( $pdf_id == 123 ){
            return 'black'; // default is 'white'
        }
        return $bgcolor;
    }, 10, 2 );
    ```

### pdf_thumbnail_page_number

Maybe you want to PDF thumbnail page number for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_page_number', function( $page, $pdf_id ){
        if( $pdf_id == 123 ){
            return 1; // default is 0
        }
        return $page;
    }, 10, 2 );
    ```

### pdf_thumbnail_filename

Maybe you want to PDF thumbnail filename for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_filename', function( $filename, $pdf_id ){
        if( $pdf_id == 123 ){
            return str_replace( '.pdf.png', '.png', $filename );
        }
        return $filename;
    }, 10, 2 );
    ```

### pdf_thumbnail_imagick

Maybe you want to add watermark to PDF thumbnail for a specific PDF file

    ```
    add_filter( 'pdf_thumbnail_imagick', function( $imagick, $pdf_id ){
        if( $pdf_id == 123 ){
            // add your watermark here
        }
        return $imagick;
    }, 10, 2 );
    ```

### get_pdf_thumbnail_image_attributes

Maybe you want to change attributes for image tag from `get_pdf_thumbnail_image`
function

    ```
    add_filter( 'get_pdf_thumbnail_image_attributes', function( $attr, $pdf_id ){
        $attr['loading'] = 'eager';
        return $attr;
    }, 10, 2 );
    ```

### pdf_thumbnail_generated

Maybe you want to do something after the thumbnail is generated

    ```
    add_action( 'pdf_thumbnail_generated', function( $thumbnail_path, $pdf_id ){
        // do somthing with the local file $thumbnail_path
    }, 10, 2 );
    ```

## Skærmbilleder

 * [[

## Installation

 1. Upload `pdf-thumbnail-generator` directory to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

## FAQ

### Plugin requirements

PHP 5.6 or higher
 Imagick extension

### PDF thumbnails stored location

PDF thumbnails are generated in the same directory as original PDF file. Example:

pdf file: `/wp-content/uploads/2022/01/example.pdf` thumbnail: `/wp-content/uploads/
2022/01/example.pdf.png`

## Anmeldelser

![](https://secure.gravatar.com/avatar/53f7547b0ab3852017f7e4dd8b6dc6993b46c8b9f71ec59c8cc1457a08b885aa?
s=60&d=retro&r=g)

### 󠀁[Great Little Plugin](https://wordpress.org/support/topic/great-little-plugin-365/)󠁿

 [DarkLight Digital](https://profiles.wordpress.org/darklightlaser/) 17. februar,
2025

Does what it says on the tin! Generates a thumbnail which can be used however you
need to. Great for building a library of pdfs – wrap the shortcode in a link and
BANG, you’re done!

![](https://secure.gravatar.com/avatar/5e5750dffa01a908cef8e9630bb6febf08e8e533796793a3c74e11743fd19edf?
s=60&d=retro&r=g)

### 󠀁[Invaluable for building document libraries and the like](https://wordpress.org/support/topic/invaluable-for-building-document-libraries-and-the-like/)󠁿

 [Jeremy Varnham](https://profiles.wordpress.org/jvarn13/) 1. august, 2024

I’ve used this on multiple sites and have found it invaluable. While I’ve struggled
with getting the required ImageMagick set up and working on a few servers – each
one requiring a slightly different approach owing to different OS and security settings–
this is not the fault of the plugin or plugin author. I’m not sure what one reviewer
means by this being built-in to WordPress; to the best of my knowledge that is incorrect.

![](https://secure.gravatar.com/avatar/303518c80f6f6085242214a06a4fadfee403716e4606b4e220c8af7fdb0fd594?
s=60&d=retro&r=g)

### 󠀁[Very Helpful, Simple Yet Customizable](https://wordpress.org/support/topic/very-helpful-simple-yet-customizable/)󠁿

 [hommealone](https://profiles.wordpress.org/hommealone/) 19. juli, 2024

In certain situations, this can be a very handy plugin. It works as advertised. 
It is simple to use, and allows developers many options of how to implement it and
customize it when needed. Using custom fields for file uploads, I’ve built this 
into template files, so my customers can simply upload their PDF files and have 
them presented nicely with no further effort required. In the right situation, it
can save many tedious and repetitive steps. It allows my clients to easily and automatically
present their PDF files in an attractive way without having to fire up Photoshop
or some other image creation method each time. No more need to upload a PDF file
and a separate image file. This plugin takes care of it all in one easy step. p.
s. – the developer seems to be excellent at responding to questions in the plugin’s
forum page too!

![](https://secure.gravatar.com/avatar/c991016c01b61fc526373d0e969c8485560730bca47f573c9a61a79353196b26?
s=60&d=retro&r=g)

### 󠀁[Possible data security issue](https://wordpress.org/support/topic/possible-data-security-issue/)󠁿

 [Hanno](https://profiles.wordpress.org/bsoftde/) 13. februar, 2024 2 svar

This plugin does not work with ImageMagick’s current default settings. In order 
to make it work you have to change IM’s settings and thus open a possible security
hole (cf. “ImageMagick security policy ‘PDF’ blocking conversion” on StackOverflow).
But if you do so, you don’t need that plugin at all, because WordPress then does
the thumbnail generation out of the box, and those image files only have 10 percent
the size of those generated by this plugin.

![](https://secure.gravatar.com/avatar/2225189e8044df879b3326c1371fcd0b2ce35b545f212ee06d580bab8c273539?
s=60&d=retro&r=g)

### 󠀁[High level of customization](https://wordpress.org/support/topic/high-level-of-customization/)󠁿

 [cvladan](https://profiles.wordpress.org/cvladan/) 28. december, 2022

This plugin exceeded my expectations by allowing me to dynamically preview a PDF
file without any links to it or similar. One of the standout features of this plugin
is its high level of extensibility. With numerous hooks provided, it is easy to 
customize and tailor the plugin to meet specific needs and requirements.

![](https://secure.gravatar.com/avatar/89b43d8d32b1049c31184d69670160c3bb02d1f74506aaf427b2f921278eb5a1?
s=60&d=retro&r=g)

### 󠀁[Very Useful Plugin](https://wordpress.org/support/topic/very-useful-plugin-1374/)󠁿

 [hilmon](https://profiles.wordpress.org/hilmon/) 10. oktober, 2022

Plugin works great. Very easy to use and implement.

 [ Læs alle 6 anmeldelser ](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/)

## Bidragsydere & udviklere

“PDF Thumbnail Generator” er open source-software. Følgende personer har bidraget
til dette plugin.

Bidragsydere

 *   [ kubiq ](https://profiles.wordpress.org/kubiq/)

“PDF Thumbnail Generator” er blevet oversat til 1 sprog. Tak til [oversætterne](https://translate.wordpress.org/projects/wp-plugins/pdf-thumbnail-generator/contributors)
for deres bidrag.

[Oversæt “PDF Thumbnail Generator” til dit eget sprog.](https://translate.wordpress.org/projects/wp-plugins/pdf-thumbnail-generator)

### Interesseret i udvikling?

[Gennemse koden](https://plugins.trac.wordpress.org/browser/pdf-thumbnail-generator/),
tjek [SVN repository](https://plugins.svn.wordpress.org/pdf-thumbnail-generator/),
eller abonner på [udviklerloggen](https://plugins.trac.wordpress.org/log/pdf-thumbnail-generator/)
via [RSS](https://plugins.trac.wordpress.org/log/pdf-thumbnail-generator/?limit=100&mode=stop_on_copy&format=rss).

## Ændringslog

#### 1.5

 * tested on WP 6.9
 * new shortcode [pdf_clickable_thumbnail id=”123″] displays clickable PDF thumbnail
   that will open PDF in new tab on click
 * csrf security fix

#### 1.4

 * fix: more URL escaping

#### 1.3

 * tested on WP 6.6
 * escape URL in admin link to prevent XSS

#### 1.2

 * tested on WP 6.5

#### 1.1

 * tested on WP 6.4

#### 1.0

 * First version

## Meta

 *  Version **1.5**
 *  Senest opdateret **4 måneder siden**
 *  Aktive installationer **2.000+**
 *  WordPress-version ** 3.0.1 eller højere **
 *  Testet op til **6.9.4**
 *  PHP-version ** 5.6 eller højere **
 *  Sprog
 * [English (US)](https://wordpress.org/plugins/pdf-thumbnail-generator/) og [Japanese](https://ja.wordpress.org/plugins/pdf-thumbnail-generator/).
 *  [Oversæt til dit sprog](https://translate.wordpress.org/projects/wp-plugins/pdf-thumbnail-generator)
 * Tags
 * [creator](https://da.wordpress.org/plugins/tags/creator/)[generator](https://da.wordpress.org/plugins/tags/generator/)
   [image](https://da.wordpress.org/plugins/tags/image/)[pdf](https://da.wordpress.org/plugins/tags/pdf/)
   [thumbnail](https://da.wordpress.org/plugins/tags/thumbnail/)
 *  [Avanceret visning](https://da.wordpress.org/plugins/pdf-thumbnail-generator/advanced/)

## Bedømmelser

 4.3 ud af 5 stjerner.

 *  [  5 5-stjernet anmeldelser     ](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/?filter=5)
 *  [  0 4-stjernet anmeldelser     ](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/?filter=4)
 *  [  0 3-stjernet anmeldelser     ](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/?filter=3)
 *  [  0 2-stjernet anmeldelser     ](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/?filter=2)
 *  [  1 1-stjernet anmeldelse     ](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/#new-post)

[Se alle anmeldelser.](https://wordpress.org/support/plugin/pdf-thumbnail-generator/reviews/)

## Bidragsydere

 *   [ kubiq ](https://profiles.wordpress.org/kubiq/)

## Support

Problemerne er løst inden for de sidste to måneder:

     0 ud af 1

 [Vis supportforum](https://wordpress.org/support/plugin/pdf-thumbnail-generator/)

## Donér

Vil du gerne støtte udviklingen af dette plugin?

 [ Donér til dette plugin ](https://www.paypal.me/jakubnovaksl)