When WordPress Will Not Upload Images

* This page contains promotional content

When WordPress will not upload images, the following points are often raised

  • The destination for the images is not writable
  • You are going over the image size limit set in php.ini
  • An image compression plugin is involved
  • There is simply not enough disk space
  • CPU load has hit 100%

Uploads stopped working from 2019?

In particular, the symptom of an error occurring kept happening even though I had not changed php.ini or any plugin.

画像の後処理に失敗しました。このファイルが写真もしくは大きい画像であれば、2500ピクセルに縮小してから再度アップロードしてください。」

Apparently some people have it fixed by the following

  • Restart the browser once
  • Log out of the admin screen
  • Save it as a draft once

In my environment, however, none of that solved it

Cause

  • A problem caused by the combination of WordPress and PHP versions
  • A defect in a WordPress plugin

Workarounds

If it is a problem with the PHP version, at this point there is nothing to do but wait for a WordPress bug fix, so it seems that people in a hurry have no choice but to do the following

Follow-up investigation

When I tried out environments in Docker with WordPress 5.3 and different PHP versions, the upload problem did not occur in any of them

WordPressPHPResult
5.3.27.0
5.3.27.3
5.3.27.4

Resolution

From the results of the Docker verification, I concluded that this was not about compatibility between WordPress and PHP, but that something else in the environment was affecting it

In my environment I run kusanagi-nginx and kusanagi-php with Docker-compose, and since the PHP environment was 7.0 I tried updating it to 7.3, but PHP threw an error and would not even start.

I had quite few WordPress plugins, and disabling them did not clear the problem either; the cause this time turned out to be the image optimisation in the KUSANAGI settings playing up.
When I disabled it, images became uploadable just like that.
What is more, turning it back on again does not bring the problem back — is it the cache?? (a mystery

In WordPress, cache-related and compression-related features are a minefield!