Getting an error message uploading images to WordPress is frustrating but here is a step by step guide to fix this.
One thing I recommend before you start using WordPress is to get to grips with the media library. If you are creating an e-commerce store or starting a busy blog it needs careful management. The media library can get overloaded and messy, only keep images you are using for example.
Here is a quick guide to help you identify the issue and fix it quickly.
[lwptoc]
1. Check file permissions
You should have access to the files on the server, so the first step is to check you the file permissions to enable the uploads.
File permissions dictate who can modify files and folders on the server.
There are three types of user: User (administrator), Group (user roles i.e. editor) and World (anyone)
There are three types of actions for the user: Read, write, execute
The ideal permissions ensure hackers don’t upload malicious code to your website, hence the permissions are very important. Only the Administrator should have access to write anything to the website.
Check the folders and files have the permissions below:
Folders: 755
Files: 644
2. PHP Execution time
There maybe cases where you get the following message, or you may get a message that is more specific.
“An error has occurred. Please try again”
Check the server execution time is set to 300, you can do this be modifying your wp-config.php file with the code below:
set_time_limit(300);
Or you can add the code to your .htaccess file
php_value max_execution_time 300
3. Increase WordPress memory limit
When I build a website I usually increase the WordPress memory limit as a matter of course. If the memory limit has not been increased from the default it could cause a 503 error.
Add the following code to your wp-config.php:
4. Check PHP is current version
WordPress website Managers spend a lot of time updating plug-ins and themes to keep the websites running efficiently.
We also need to ensure the website is running on the current PHP version, this can only be actioned via the server i.e. cPanel.
If you do not have access to the host server then contact your host provider.
5. Ensure imagick is enabled in php
There are various modules in PHP and WordPress now has a tool that checks that you have all the necessary modules.
You can check this when you go to Tools, site health. It will show you if any of the required modules need to be added i.e. imagick.
6. Issue with optimizing plug-in
Website designers and developers are tasked with delivering a fast and effective websites so sometimes we use optimizer plug-ins that minimize content, deactivate one of these plug-in’s to see if it is causing an issue with the image uploads.
In my case, it was Autoptimize that was hindering the upload process, so this has been temporarily deactivated.
Often the plug-in issues can be fixed on the next update. Keep a note of the plugin-in you have deactivate and once the next update has been carried out try and re-activate and test the uploads.
7. Clear the cache
We always have a caching plug-in on the website to manually clear the cache once an error has been resolved.
Clearing the cache will clear all the memory of the issues and gives you a clean slate.
Just clearing the cache can sometimes fix the error.
Summary
Images are vital to your website user experience but they need careful management. Images do need to be optimized and labelled correctly before uploading, file permissions need to be set correctly and there needs to be enough memory on the host server.
If you need any further information or assistance please contact me.