How to Fix HTTP Error when uploading images to WordPress

Errors could be frustrating, but it’s quite common for a website user. Quickly, know how to fix HTTP errors when uploading images to WordPress.

It is easy to create a website in WordPress and add several features to it through the large variety of plugins available.

Sometimes conflicts between the plugins may also result in that HTTP error. Here, we will look at some possible ways to solve this HTTP error while uploading an image.

How To Fix HTTP Error while Uploading Images to WordPress

Though all the ideas are going to be simple to get rid of, let’s go with the most simple one.

Fix 1: By Changing the File Extension

Change the image format from.png to .jpg, and similarly vice versa, and simply re-upload again to your WordPress website.

If this doesn’t work, let’s move on to the second one.

Fix 2: Through Plugin

Fix HTTP errors by using a plugin. Simply install a plugin called Default to GD from Github

Click on the “Clone” or “Download” button, and then click on “Download ZIP” and download the plugin.

If this doesn’t work, then you can make the plugin on your own. Below is the source code for the same.

<?php
/*
Plugin Name: Default to GD
Plugin URI: http://wordpress.org/extend/plugins/default-to-gd
Description: Sets GD as default WP_Image_Editor class.
Author: Mike Schroder
Version: 1.0
Author URI: http://www.getsource.net/
*/
function ms_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’, ‘ms_image_editor_default_to_gd’ ); 

Copy this code. Go to your server root directory and find wp-content > Plugins.

Simply create a directory as default to GD, and then create a file in it  default-to-GD.php and add the above code into it.

That’s it, you are done, and you won’t be receiving any HTTP image errors going forward.

If, this sounds complex, check the other ones

Fix 3: By Adding code in functions.php

You can also add a snippet to your theme as well.

Navigate to your AppearanceEditor, and then find the functions.php file and add the below code at the bottom.

add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ );

function change_graphic_lib($array) {
return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ );
}

Fix 4: Increase PHP Memory

You can always contact your hosting provider to do the same to increase the PHP memory.

But, I would say, do it yourself by simply adding the code to the wpconfig.php file.

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

This action will increase the WordPress PHP memory limit if restricted. You can try changing it to 256M as well to get the issue solved.

Fix 5: Via .htaccess

You can also make it through the .htaccess file by adding a small snippet.

Note: Always backup the .htaccess file before making any edits. Just being on the safer side.

Add the below code at the top of the .htaccess file

AddType x-mapp-php5 .php

Final Words on the HTTP Image Error:

These WordPress tricks work great. After getting that error, I have tried, and fortunately, all are working. Get rid of that freaking error.

Do let me know which one you tried and worked for you. Share it around if this helps. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *