2. Increase WordPress Memory Limit

The most common cause of this error is lack of memory available for WordPress to use. To fix this, you need to increase the amount of memory PHP can use on your server.

You can do this by adding the following code to your wp-config.php file.

define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

This code increases the WordPress memory limit to 256MB, which would be enough to fix any memory limit issues.

3. Change Image Editor Library Used by WordPress

WordPress runs on PHP which uses two modules to handle images. These modules are called GD Library and Imagick. WordPress may use either one of them depending on which one available.

However, Imagick is known to often run into memory issues causing the http error during image uploads. To fix this, you can make the GD Library your default image editor.

You can do this by adding this code to your theme’s  functions.php 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’ );

After adding this code, you can retry uploading files using the media uploader. If this doesn’t solve the issue, then you can remove this code and try the methods below described in this article.

4. Using the .htaccess Method

This method allows you to control how Imagick uses server resources. Many shared hosting providers limit Imagick’s ability to use multiple threads for faster image processing. However, this would result in you seeing the http error when uploading images.

An easy fix is be to add the following code in your .htaccess file:

SetEnv MAGICK_THREAD_LIMIT 1

This code simply limits Imagick to use a single thread to process images.

Conclusion

Getting the HTTP error when uploading images to WordPress is not the best of feelings. We are, however, confident that one of the solutions above will fix this error once and for all.

Have you ever encountered the WordPress HTTP error before and fixed it with a different solution? If so, don’t hesitate to share your experiences in the comment section below!

LEAVE YOUR COMMENTS