Mon. Jun 27th, 2022
How to Fix the HTTP Image Upload Error in WordPress

WordPress is a major CMS (Content Management System) used by millions of websites across the globe. When it works, it works beautifully. Very little technical knowledge is required to maintain a WordPress website and most people never encounter any issues besides the usually Plugin bugs.

However, strong and powerful as WordPress is, it is not infallible. Plugins can seriously screw up a WordPress website if they’re incompatible or simply coded badly by the developer, but that’s not the only way your website can fail.




Server misconfiguration, Cloudflare misconfiguration, and bad cache settings, all can have a serious impact on your website’s performance and usability.

One of the most common issues that WordPress users may face is the dreaded HTTP Image Upload Error.

What is the HTTP Image Upload Error in WordPress?

This error usually rears its ugly head when you try to upload a photo via the Gallery / Media interface. You’d get an error right after the upload finishes and the image doesn’t save in the website’s gallery.

There are many causes for this error and the “HTTP Error” message WordPress throws is basically its way of saying “I have no idea why the upload fails. You’re on your own”.




Fortunately, this issue has some very common causes and it can be fixed.

How to Fix the HTTP Image Upload Error in WordPress

1. Hosting / server issues

Let’s start with the beginning: your hosting service. Is everything ok there? Are they doing any sort of planned (or unplanned) maintenance to the servers? Especially if you are on Shared Hosting, it may be that the error is caused by your host working on the servers.

While uncommon, it can happen that certain server updates a hosting company may do would result in your website breaking.

You can check if there’s any ongoing maintenance or issue with the hosting service by either checking their Status page or by contacting their support.

2. Cloudflare misconfiguration

Are you using Cloudflare or any other CDN (like Fastly) to serve your website? If so it could be an issue with the Firewall or the caching on those. If you did any sort of modification lately to your CDN / Cloudflare Dashboard, a good starting point would be to revert those changes and clear the cache.

If the error persists, put your website in Development Mode in Cloudflare to make sure you bypass their caching while you work on a fix.

3. Is the file too big? Maybe a corrupted format?

Files can get corrupted. If WordPress is unable to process the file because it’s of a foreign format or it has been corrupted, it may spit out an error. It’s unlikely it’d be the HTTP error, but it did happen before. Same with the file size.

To test this, go ahead and download a picture of a cat from Google Images. Make sure it’s JPEG or PNG, not WebP, and try to upload it. If it works, there’s an issue with the image you try to upload. If the known-good cat picture doesn’t upload either, the issue is much deeper than your files.

4. Increase WordPress’ Memory Limit

It’s very common for this error to be caused by low memory available to WordPress, especially on Shared Hosting or low-tier hosting plans which bottleneck your available CPU and RAM on the server.

You can change the parameter in wp-config.php file to give WordPress more memory to play with, but you can’t give it more than your server allows on your hosting plan.




To change the memory limit, edit the wp-config.php file on the following line:

define( 'WP_MEMORY_LIMIT', '256M' );

Replace the line of code in your file with the one from above. It should increase the memory limit to 256 MB which should be enough to fix the issues.

5. Make GD Library your default image editor

By default, WordPress relies on whatever PHP makes available for image processing. The two libraries PHP can make available to WordPress are GD Library and Imagick. However, Imagick is known for often having memory issues, especially on Shared Hosting, so you may try to set GD Library as your default image processor for WordPress.

To do this, you need to edit your current theme’s functions.php (Via the Appearance->Theme File Editor in WordPress Dashboard) and add the following code at the end of the file:

function wpb_image_editor_default_to_gd( $editors ) {
    $gd_editor = 'WP_Image_Editor_GD';
    $editors = array_diff( $editors, array( $gd_editor ) );
    array_unshift( $editors, $gd_editor );
    return $editors;
}
add_filter( 'wp_image_editors', 'wpb_image_editor_default_to_gd' );

Other common reasons the error may occur

  • No more space is available on disk. Especially if you’re running on Shared Hosting.
  • The firewall (Cloudflare’s or otherwise) is set too high and is blocking the upload.
  • You’ve accidentally password-protected the WP-ADMIN folder and the PHP files can no longer be called properly.

Credits

Click to rate this post!
1

By GeoSn0w

An iOS and Jailbreak enthusiast who has been around for quite some time in the community. I've developed my own jailbreaks before and I am currently maintaining iSecureOS, one of the first iOS Anti-Malware tools for jailbroken devices. I also run iDevice Central on YouTube with over 133.000 Subscribers! Thank you for being part of this awesome community.

Leave a Reply

Your email address will not be published.