Recently we published our Complete Guide to Fix WordPress Errors,
Well at that time my blog was just started so I didn’t post that solution, but its never too late to help others fixing this weird problem.
Download this quick printable guide on Fixing any Kind of WordPress Errors.
Basically with this problem you could not upload any image in WordPress, and if the upload goes through it will show images in the media library as broken. In this article, we will show you how to fix image upload issue in WordPress.
This are the reasons why you can face the WordPress Error Uploading Images.
- Image Size
- PHP Memory
- Plugin conflict
- File Permission
- PHP Version on Server
This happens when you are trying to upload an image that is large in pixel size, for example an image with 4000 x 3000 pixel. Which is too large for your server to process.
Some server shows error even when your image is less than that size, it all depends on your server resources.
Decrease the image’s size. Don’t add a very large pixel image, for example. If your post content area is 800px wide, don’t add an image larger than that.
Reduce image size by trial and error until you are able to upload it without any error. 1075px is enough for most wordpress site, if you are using a premium wordpress theme check its documentation to know the image size required.
As it won’t have enough room to expand and all it do is shrink up to that space, the problem is that while uploading that size of image the wordpress will consume huge amount of memory. Since some server limits the amount of memory that can be consumed by a wordpress, in this case it will cause an error while uploading.
WordPress functionality and resources can be limited afterall it runs on PHP and the servers running PHP can limit this resources.
You can increase your PHP memory either by all yourself or ask your web hosting support team. The memory can be increased in 2 ways:
- Increase WordPress Memory
- Increase PHP Memory
You can increase the wordpress memory by adding this code in your wp-config.php which is located in your wordpress root directory.
<strong> define('WP_MEMORY_LIMIT', '256M'); </strong>
This above setting may not work if your host/server does not allow you to increase the PHP memory limit or limits it to some extend, so I suggest talking to your support directly and ask them to change the limit for you. You’ll skip the hassle. Its better ask the support team to increase your PHP memory, but if you love the hassles then add this below code to your php.in or php5.ini
You may have never noticed this security or you know about this. ModSecurity is also known as .htaccess and I hope you have seen this file in your wordpress root directory, mostly its hidden.
If your server has mod security enabled then may be in your case this file is causing the problem.
You need to disable the mod security for your upload so create a .htaccess inside the wp-admin folder and add the following codes.
That will disable mod_security for the upload file receiving code in the wp-admin.
Note: Remove this if it’s causing any error on your server.
It has been confirmed that in major of the cases a plugin has been conflicting with the upload process. In many cases even my blog has suffered from plugin conflicts.
its due to some out dated plugin or some syntax error that was triggered due to upgrading to latest version of one or other plugin or the wordpress.
I have found that plugins that helps in uploading, shrinking or compressing images mostly case the error. In some cases some desktop application had also triggered this error if you use that apps to compress or render images.
Also jetpack, plugins that help upload to cdn or aws or remote servers causes wordpress error on uploading images.
Please proceed to disable one plugin at a time. Clear your cache and browser history and revisit media uploader to upload your image and see if you are successful.
If not try not to use any wordpress plugin and desktop apps and upload a raw .png or .jpg and check whether it works or not.
If its not a plugin or a limited memory that causing the error while uploading the images then i would sugest you to have a look at the file permission on your server.
File permission can change automatically even if you didn’t change it.
Want to know. How it Changed?
If you hosting company run an upgrade on their servers or a plugin has been updated by you then the file permissions can be changed.
If you are using a shared web hosting then the possibility is that a hacker have accessed your files and your file permission may have been changed by a payload that the hacker may have uploaded.
You can change the file permission easily via a FTP program, I use cyberduck for ftp on both my mac and windows pc.
How to Use FTP for your WordPress.
Access your files through ftp and and then go to /wp-content/ directory. There you will see /uploads/ folder. Right click on the uploads directory and select file permissions.
At first you will need to set file permissions for uploads directory itself and all the sub directories inside it to 744. To do that, enter 744 in the numberic value box, and then check the box next to Recurse into subdirectories.
Lastly, you need to click on ‘Apply to directories only’ radio button. Click on the OK button to apply these changes.
You need to repeat the same process but for the uploads folder.
You will need to set file permissions for all the files in the uploads directory. To do that, right click on uploads directory and select file permissions.
In the file permissions dialog box change the numeric value to 644. Check the box next to Recurse into subdirectories. Click on Apply to files only radio button. Click on the OK button to apply these changes.
Your FTP program will apply this changes and your image uploader will work again
PHP Version on server
It remains unnoticed through out the entire task you do while solving this error, As in most of the cases no one think about this.
Why should anyone, as in most cases the users say it was working till yesterday before I hit that update button.
But updating the plugin, theme or wordpress can trigger this error and several other errors, as wordpress is built upon PHP and it has some standards to follow, so the developer always stats the version which is stable for wordpress.
If your server php version is not the same as required by the wordpress, then contact your server support staff and ask them to make the changes of your PHP version to the requirement of wordpress.
(Update). This fix was pointed out by a couple of our readers. We thank them for that!
Make sure you don’t have an apostrophe in the image file’s name (e.g. john‘s-blogging.png), because that will trigger the error as well.
(Update). If you’re using an image optimizer plugin, deactivate the plugin and see if that solves the issue.
If you are still facing the problem, then let me know. I will be happy to help you 🙂 And comment below which method worked for you to fix this error.