Wordpress PDF not returning the sizes array for thumbnail

54 views Asked by At

I seem to be missing something because I cannot pull the pdf cover or thumbnail despite meeting all the requirements (same code seems to be working on other sites I own).

What am I missing?

I've ran the PDF Thumbnails Support Test and it shows that I have all the required PHP extentions. When I upload a PDF file of a magazine either with ACF or directly in the media upload folder, I cannot retrieve the sizes array which contain thumbnails.

//First I try to get the attachemnt id - either by hardcoding it or retrieving it from somewhere
$attachment_id =  get_field('file_test','options'); 

//then I use wp function that returns sizes if the file is an image
$attachment_meta = wp_prepare_attachment_for_js($attachment_id); 

$attachment_meta does not return array key "sizes" on certain sites.

Site is running on WP 6.3.2

Imagick 3.7.0

Ghostscript 9.53.3

PHP 8.1.21

1

There are 1 answers

0
HNNX On

Found the solution - ImageMagick prevented PDF thumbnail from generating. In the folder /etc/ImageMagick-6 I found policy.xml and replaced

<policy domain="coder" rights="none" pattern="PDF" /> 

with

<policy domain="coder" rights="read|write" pattern="PDF" />