Wordpress image editor not working on LEMP 16.04

Can’t get image editor to work in WordPress Media, only shows this error message “Could not load the preview image. Please reload the page and try again.”

I went to see if I have both gd & imagick installed and enabled

Running both these commands I can see that they are enabled and installed

php -i | grep -i gd
php -i | grep -i magick

and reloading using

sudo service ph7.0-fpm restart

it still doesn’t work. Also enabled debugging/debug log in wp-config.php to see if anything shows up but nothing in the error log.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

From what I can tell, you need to dig into your PHP error logs (might show up in Nginx error logs). This is usually caused by a WP plugin (or theme) that has a space after the code, which results in a “header already sent” error from PHP. Try disabling all your plugins and changing theme to default 2017 and see if that helps. If yes, then active one-by-one.


Have you checked user permissions on your files and directories? By default, PHP-FPM runs as the www-data user, so all files and directories would need to be owned by that user in order for PHP to be able to read/write.

You can cd to your root directory (where ./wp-config.php is) and run:

ls -al

… and that should give you the user and group that owns the files. If it’s root or another user, you can run:

chown -R www-data:www-data /path/to/root

… and that’ll change permissions to www-data, thus allowing PHP to read and write to files.