How to Fix HTTP Image Error in WordPress?

There could be many reasons which causes an HTTP error when you are trying to upload the files, by using the WordPress media uploader. Here the WordPress will be unable to figure out the causes and that is the reason it displays a generic ‘HTTP error’ message.




Here the frustrating part is that the error message will not give you any type of clues on the reasons of its cause. This would mean that one has to try different solutions for finding the cause and how to fix the error.

First and foremost thing that needs to be performed is to try uploading the image file again. This error can crop up because of unusual traffic and a low server resources, this will be automatically fixed on the WordPress hosting servers.

It it isn't working then you would be required to try uploading a different image file. If the other file is able to upload successfully then you can try saving the original image file to a smaller size and then retry the uploading.


You would like to try saving the file to a different file to a different format. Here for example changing jpeg to png using an image editing software. After that you can try uploading the file.

If all of these steps are resulting in an HTTP error, then it would mean that error is not been caused by a temporary glitch and it will need an immediate attention.


Increasing WordPress Memory Limit


Here in this case the most common cause of the error is the lack of memory which is available for the WordPress to use. For fixing this you will be required to increase the memory PHP which can be used on the server.
You will be able to do it by adding the following code to the wp-conif.php file.

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

Here this code increases the WordPress memory limit to 256MB, this memory would be enough for fixing any kind of memory limit issues.

 

 

 

Here the WordPress runs on PHP which uses two modules for handling the images. These modules are called as the GD Library and Imagick. WordPress may be using either one of them depending on which of the one is available.

 

The Imagick can run into memory issues that causes the http error during the image uploads. For fixing this you need to make the GD Library as the default image editor. You will be able to do this by simply adding the code to the theme functions file or the site specific plugin.

 

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' );

 

Once the code has been added you can try uploading the files which is using the media uploader. Even after adding the code if the problem is not solved then you can remove the code and then try other methods as it has been discussed.

Using the .htaccess Method

This is the method which will allow the user in controlling how Imagick uses the server resources. There are many shared hosting service providers which limit the ability of using the multiple threads for a faster image processing. However this will be resulting in seeing the http error when uploading of the image.

 

You can add the following code in the .htaccess file:

SetEnv

MAGICK_THREAD_LIMIT 1

 

This code will simply limit the imagick for single thread for processing the images.