Fixing persistent WordPress image upload problems – and saving some disk space too

For months this blog has been beset by a problem. Every time I upload an image I would receive the error:

Post-processing of the image failed. If this is a photo or a large image, please scale it down to 2500 pixels and upload it again.

Scaling it down, or increasing the JPG compression, would work in perhaps 1 in 5 cases, but not universally. Sometimes an image would be useable even if the error had shown, and sometimes it would not.

I had assumed this was a memory problem – I only have shared hosting for this blog – but increasing the memory allocation in cPanel (editing php.ini) made no difference. Changing the PHP version made no difference either (see latter points here). Using the Disable “BIG Image” Threshold plugin did not work.

So what did work?

The solution was to add a line of code to functions.php, as outlined here. This is the line:

add_filter( ‘wp_image_editors’, function() { return array( ‘WP_Image_Editor_GD’ ); } );

This forces WordPress to use the GD image editor, rather than ImageMagick.

And it works! Problem solved…

But hang on… messing around with the functions.php file is not very handy, not least because there are still 90 odd WordPress sites running on a server I am responsible for. Were themes to then be updated by my clients – even by accident – the problem will re-occur. Yes, I could make a child theme for each one of them, but that is going to take ages and ages.

So I needed a quick way to add a line to functions.php – and there is a plugin for that. It’s called My Custom Functions and it’s explained here, towards the bottom.

It works. Image uploads now fixed in a simple and upgrade-proof manner.

But then what to do about clients uploading massive images – and using up loads of disk space and potentially also bandwidth as a result? Here I have come across a further plugin – Imsanity – that force resizes images according to user set parameters, saving on disk space. The combination of the two works just fine.

Share this
  • 28.09.2020
Jon Worth's Euroblog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.