Home Forums Feature Requests Show PDF Thumbnails on file uploads if available


Show PDF Thumbnails on file uploads if available

  • Now that WordPress 4.7 supports creating thumbnails for PDF’s (Assuming the server you’re on has GhostScript installed). Would it be possible to show the preview thumbnail for files that are PDFs, when uploaded in wp-admin?

    It’s been great for a new project that I don’t need to create a second field for the PDF Thumbnail.

    Currently it’s just a file icon, which is fine, but I think it would look nicer if the client can see what they just uploaded.

  • Now that it’s possible in WP core, I’m sure it will be added sooner or later, depending on what everything else the developer is working on and his priorities. You should submit this to support if you want the developer to see it sooner rather than later

  • Hello,

    FYI, I had same issue and did this hook to make it:

    function acf_change_icon_on_files ( $icon, $mime, $attachment_id ){ // Display thumbnail instead of document.png
    		if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) === false && $mime === 'application/pdf' ){
    			$get_image = wp_get_attachment_image_src ( $attachment_id, 'thumbnail' );
    			if ( $get_image ) {
    				$icon = $get_image[0];
    		return $icon;
    	add_filter( 'wp_mime_type_icon', 'acf_change_icon_on_files', 10, 3 );
  • @jonas Thanks! This is perfect 🙂

  • Hey @jonas, $get_image = wp_get_attachment_image_src ( $attachment_id, 'thumbnail' ); doesn’t seem to be returning anything for me, any ideas? ($icon, $mime, and $attachment_id are all returning correct data)

  • Hello,
    Yes, there’s probably the following reason to that..

    => You may have WordPress 4.7+ with an hosting where Imagemagick or Imagick AND ghostscript are installed. Else you will not have the new wordpress option that automatically create an image preview of your PDF stored as an attachement image. More info here:

    If you don’t have this option automatically activated, there’s 2 possibilities to try:
    1) you might maybe find a plugin that add the option to set a featured image to your PDF attachment… then you’ll need to manually attach the image to your PDF each time you download one.

    2) Else, try the following plugin – as WP 4.7 feature – it also require Imagemagick and Ghostscript, but for an unknown reason it was working for me on a website where the default WP 4.7+ behaviour were not working:

    I don’t have more time to investigate, but if someone has the reason why this plugin works where WP 4.7 doesn’t, i’m curious of the answer.

  • @jonas that function is awesome! You are awesome. Thank you!

  • Now it seems as if PHP8 doesn’t support Imagemagick or Ghostscript…
    So I end up using a paid version ($20) to show my PDF thumbnails that doesn’t use modules called

    It works with ACF upload field and the render template code as well as @jonas code!!

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Show PDF Thumbnails on file uploads if available’ is closed to new replies.