I'm trying to generate thumbnails for a PDF attachment. Right now in the uploads/ folder there is only the PDF file, no image thumbnails related to it.

But when I run the regeneration with :

wp media regenerate 1188810 --image_size=portrait_medium

it shows this message :

Found 1 image to regenerate.
1/1 No "portrait_medium" thumbnail regeneration needed for "Products catalog" (ID 1188810).

I dont understand why it says no thumbnail regeneration is needed when that's not the case.

My custom image sizes are defined like this in functions.php :

add_action( 'after_setup_theme', 'mwm_custom_image_sizes' );
function mwm_custom_image_sizes() {
    add_theme_support( 'post-thumbnails' );
    add_image_size( 'portrait_medium', 200, 286, array( 'center', 'top' ) );

1 Answer 1



Note that this solution may introduce a security flaw in your site. Use it with extreme caution.

On my installation, I got a warning when I tried to regenerate PDF thumbnails:

attempt to perform an operation not allowed by the security policy `PDF'

...which, upon searching for that string, appears to indicate that imagemagick (which does WordPress's image handling) won't process PDF files.

A comment on a support thread had this to say:

Parsing PDF was disabled[1] in /etc/ImageMagick-7/policy.xml due to its inherent insecurity. The same thing did Ubuntu and perhaps more distros will follow as this is recommendation from security researchers.

You may enable it locally by removing 'PDF' from below line: <policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,PDF,XPS}" />

[1] https://bugs.archlinux.org/task/59778

If I removed PDF from the rights="none" pattern, I was able to successfully regenerate the image(s) for the PDF file.


Note that this solution may introduce a security flaw in your site. Use it with extreme caution.

  • My ImageMagick policy is already patched like this. When I upload a new PDF, it creates the 3 default sizes successfully, it's the custom image sizes that seem to be ignored.
    – mike23
    Apr 18 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.