In this tutorial you’ll learn how to fix the HTTP error sometimes seen when uploading images to WordPress. This is actually a pretty common error and there are several ways to fix it, so let’s break it down.
Troubleshooting Uploading Errors in WordPress
Here’s a complete video version of this tutorial. Follow along with us over on our Envato Tuts+ YouTube channel:
1. Try Again or Change Browser
An HTTP error can be caused by many different things and the notification you’ll see (like the image below) is a fairly unhelpful generic message. This suggests WordPress doesn’t know the exact cause.
Sometimes the simplest fix is to try again later; try to upload the image again. One potential cause for this error is low server resources, so if you try again later and it works you’ve probably found the problem.
If that doesn’t work you could also try switching the browser. Try Firefox if you saw the error in Chrome, for example. If neither of these approaches change anything, you need to try something else..
2. Disable WordPress Plugins or Themes
If this error is thrown after you’ve installed a certain WordPress plugin or theme, that’s probably the cause. Image optimization plugins for WordPress can quite often cause an HTTP error like this to happen.
Identifying the plugin, deactivating it, then trying to upload an image again is a really good place to start. If the problem still persists, move onto the next step!
3. Resize the Image or Lower the File Size
Sometimes an error like this can be caused by an image which is too large, either in terms of dimensions or file size. Try optimizing the image to reduce its size (in Kb) or resize it before attempting to upload again.
Also, pay close attention to the file name. Sometimes filenames can contain characters which don’t sit well with the WordPress uploader.
If none of the above have worked so far, we need to look at some more complex solutions.
4. Increase the WordPress Memory Limit
One of the most common causes of this error is Insufficient Server Memory—to fix this you need to increase the amount of memory which PHP can use on your web server.
To do this we need to make a change to the wp-config.php file. This file is found in the root of your WordPress installation. Other things you’ll find in the root include the wp-content folder, an index.php file, and the .htaccess file.
Open it up in your favorite code editor, scroll to the bottom and add the following:
define( 'WP_MEMORY_LIMIT', '256M' );
Upload it to your web server again, and you’ll have increased the amount of available memory to 256Mb.
Note: this might not always work, because it can be overwritten by a server-level rule put in place by your WordPress host. If this is the case you can open up the .htaccess or php.ini file and change the memory limits there, but this is only to be advised if you’re comfortable working with these files. Alternatively get in touch with your host and explain the problem.
5. Change the Image Editor Library
By default WordPress ships with two image editors:
- imagick
- GD Library
and WordPress will use either one of these interchangeably. However imagick is known to have memory issues and is more prone to throw HTTP errors. The solution here is to force WordPress to use GD Library by adding a snippet of code to our functions.php file.
functions.php is found in your theme folder, or child theme folder in wp-content > themes > your-theme.
At the very end of it, making sure you’re within PHP tags, add the following snippet:
<?php function change_image_editor_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', 'change_image_editor_to_gd'); ?>
Save your changes, upload the file, and try to upload an image again.
6. Update to the Latest Version of PHP
Sometimes this error can happen by using an incompatible version of PHP on your server. If we look at the WordPress Requirements we’ll see the current minimum version of PHP which you need to use.
If you need to update your PHP I recommend you get in touch with your host. It really depends from host to host how they have this managed. In my case I’m using SiteGround (by the way we offer up to 60% off managed WordPress hosting on SiteGround) so I go to Devs > PHP Manager and I can keep track of things there.
In actual fact, my PHP version is updated automatically by SiteGround.
7. Ask Your Web Host for Help
If all these steps fail it might be a good idea to get in touch with your web host and ask for support. It’s possible they’ve encountered it before and will know how to help you. SiteGround, I can tell you from personal experience, has an excellent support chat service round the clock.
That Should Fix Your Image Upload HTTP Error
Hopefully these steps will help you fix your HTTP error from uploading images to WordPress. If not, or if you manage to solve things in a different way, please let us know in the comments–you’ll undoubtedly be helping others!
Useful WordPress Troubleshooting Resources
Here’s a list of tutorials and other resources to help you troubleshoot problems with WordPress.
-
HTTPHTTP Status Codes in 60 Seconds
-
WordPressTroubleshooting WordPress in 60 Seconds
-
WordPressWordPress Troubleshooting: How to Speed Up a Slow WordPress Site
No comments:
Post a Comment