Back in 2016 WordPress 4.7 added PDF thumbnail previews, meaning any PDF uploaded to WordPress would generate an image thumbnail. This handy feature improved viewing the image library and was also useful on the front end. I’m not sure when it happened, but at some point, I noticed this feature stopped working for many of my customers. Since the image preview silently fails it’s one of those things you don’t really notice unless you looking for it.

ImageMagick Policy Errors
If you attempt to use WP-CLI to regenerate the missing thumbnail with wp media regenerate <media-id>
, you will uncover the underlying error. You will see something like Warning: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
.

The problem is due to ImageMagick’s security policy being too strict. The solution taken from here requires modifying /etc/ImageMagick-6/policy.xml
or /etc/ImageMagick-7/policy.xml
depending on your system. Change this line <policy domain="coder" rights="none" pattern="PDF" />
to <policy domain="coder" rights="read" pattern="PDF" />
.
With Kinsta that is something their support needs to do. Simply refer them to this article. This fix needs to be tweaked per each environment and site. After that’s implemented run wp media regenerate --only-missing --yes
to generate any missing thumbnails.
