Varying-Vagrant-Vagrants / VVV

An open source Vagrant configuration for developing with WordPress
https://varyingvagrantvagrants.org
MIT License
4.54k stars 847 forks source link

PDF thumbnails not generated on local WordPress sites #2262

Open nathanfolland opened 4 years ago

nathanfolland commented 4 years ago

Hi all,

I've noticed that PDF thumbnail images aren't being generated when I upload documents to the media library.

I've checked that VVV comes with the PHP modules required to generate the thumbnails - everything seems to be installed.

I've tried uploading PDFs to the default sites, one.wordpress.test and two.wordpress.test, as well as some of my local development sites - none of them generate thumbnails.

Am I missing something? Do I need to enable an option to get this feature to work?

Thanks!

Windows 10 Vagrant 2.2.10 VirtualBox 6.1.14 VVV 3.4.1 WordPress 5.5.1 (various sites running default and custom themes)

welcome[bot] commented 4 years ago

Thanks for opening your first issue here! Be sure to follow the issue template and include your OS/Vagrant/VVV versions! Don't forget you can get support in the VVV slack at https://varyingvagrantvagrants.org/docs/en-US/slack/

VVV
VVV Slack Workspace
Join the VVV Slack Workspace
tomjn commented 4 years ago

Are you sure this is something WordPress can do without a plugin?

tomjn commented 4 years ago

So I looked into it, and used the debug bar media plugin and it confirmed all the tools necessary are installed. However WP did not generate the thumbnail. No errors produced, no warnings, no explanation

Am I missing something? Do I need to enable an option to get this feature to work?

Unknown. As far as I am aware, we need the appropriate tools to be installed, and they are. It should work, and there is no obvious reason why it does not. There is nothing more I can do from the VVV end of things without more information about why WP didn't attempt to create thumbnails

tomjn commented 4 years ago

it looks like WP tries to fetch an image editor for the file and none are found that can handle it, I don't know why.

It's the early hours of Sunday morning here though, so I'm going to bed

tomjn commented 4 years ago

_wp_image_editor_choose gives this:

WP_Error::__set_state(array( 'errors' => array ( 'invalid_image' => array ( 0 => 'not authorized `/srv/www/wordpress-one/public_html/wp-content/uploads/2020/10/MoneyboxTransferForms-3.pdf\' @ error/constitute.c/ReadImage/412', ), ), 'error_data' => array ( 'invalid_image' => '/srv/www/wordpress-one/public_html/wp-content/uploads/2020/10/MoneyboxTransferForms-3.pdf', ), ))
tomjn commented 4 years ago

https://alexvanderbist.com/2018/fixing-imagick-error-unauthorized/ may be the solution

Fixing Imagick's “not authorized” exception — Alex Vanderbist

Over the last few days we've had a couple of issues with Imagick and processing PDFs on our servers. As it turns out, these issues are caused by automatic security updates. Let's look into the issue and its solution.

nathanfolland commented 4 years ago

Thanks for looking into this Tom! That's fixed it.

If anybody else has this issue, open /etc/ImageMagick-6/policy.xml and change:

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

to

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

For future reference, where did you find this error? I couldn't find anything in the logs.

_wp_image_editor_choose gives this:

WP_Error::__set_state(array( 'errors' => array ( 'invalid_image' => array ( 0 => 'not authorized `/srv/www/wordpress-one/public_html/wp-content/uploads/2020/10/MoneyboxTransferForms-3.pdf\' @ error/constitute.c/ReadImage/412', ), ), 'error_data' => array ( 'invalid_image' => '/srv/www/wordpress-one/public_html/wp-content/uploads/2020/10/MoneyboxTransferForms-3.pdf', ), ))
tomjn commented 4 years ago

For future reference, where did you find this error? I couldn't find anything in the logs.

By modifying WP Core to add else statements and using var_export

If anybody else has this issue, open /etc/ImageMagick-6/policy.xml and change:

Note that manually fixing this may break the automated fix once it's implemented depending on how that's done

Mte90 commented 4 years ago

We need to do something for VVV. Maybe do that change in that file?

tomjn commented 4 years ago

I'm undecided yet on a permanent fix, wether we should search replace the file or maintain our own config to copy into place

Mte90 commented 3 years ago

I had to do the same change for imagemagick on my machine for other needs or doesn't work. I think that a sed is enough on that file as it is just a parameter and in this way we avoid issues.

Mte90 commented 2 years ago

The bug is still happening after the various release?

tomjn commented 2 years ago

@Mte90 no work has been done on this ticket, so no progress has been made