Problems uploading images in WordPress and solving them

ften problems appear while uploading images to WordPress, without knowing what caused the problem that led to the inability to upload the image, but you are immediately surprised by not being able to upload images due to user behavior or due to a technical problem on the site.

There are many reasons that lead to some problems while uploading images, such as the names of the images, their dimensions, memory-related errors, etc., among the reasons that we discuss in this article and ways to solve these problems in the simplest ways.


The most common problems with uploading images to WordPress

There are many problems that may appear to you, from an error problem during downloading, or a problem with the file size, or you cannot download at all, and others, and let us talk about these problems in more detail as follows:

1- Inability to download the image

This problem is considered one of the most common problems, and in general, you may not be able to download an image, due to the size of the image or the name of the image.

the solution:

First, you can work on changing the dimensions of the image, because sometimes the size of the image is too large or too small, so you cannot upload the image, and therefore in this case you need to change the size of the image or change its name on your computer.

You can try working on the pixlr.com program , to improve the images and set the appropriate dimensions. As for the name of the image, make sure that the name of the image or file does not contain letters such as ($, *, &, #) or letters such as (ñ, á, é).

You can also control and specify the dimensions of images, from within the WordPress control panel of your site, by going to (Settings << Media) , in order to modify the default dimensions of each image.


2- File size error

This problem occurs if the image you want to upload to your site is larger than the allowed limit.

the solution:

The solution will be to increase the file size of the maximum uploaded image by modifying the site files. In general, hosting companies often increase the maximum size of files to be uploaded to the maximum extent so that files can be uploaded easily without problems (except for shared hosting by some companies ).

Ways to increase file size:

2.1- Edit htaccess file

htaccess file can be accessed by logging in to the Cpanel panel, then going to File Manager, selecting the file, and adding the following code:

php_value upload_max_filesize 256M

Then you can try uploading the image again, and if the error still exists, you can try adding the following code:

php_value post_max_size 256M
php_value memory_limit 512M
php_value max_input_time 180
php_value max_execution_time 180

Note : You can adjust and increase the memory size as you wish, and according to what the server allows you to do.

Read also: How to use cPanel?

2.2- Modify the wp-config.php file

You can access the wp-config.php file , through the control panel or by connecting to your site via FTP and then adding the following line:

@ini_set(‘upload_max_size’ , ‘256M’);

2.3- Modify the php.ini file

The php.ini file is what controls how your server is set up. Sometimes the server will not allow you to use php.in files, so in order to access the php.ini file, from within the CPanel, you have to go to Software and choose MultiPHP INI Editor

Next, specify the Home Directory to access the file and change upload_max_filesize to a larger value

Through these methods, you will have tried to increase the allowed limit, so you can try downloading the file now.

Note: Some hosting companies do not allow you to increase the upload size limit, so you will need to contact them to do so, or change the size of the file to be uploaded.

3- The media gallery appears empty

This error occurs if you are unable to upload images or the media gallery displays empty images, or you have recently moved to another host. If you see the image as below, the problem will most likely be in the permissions for the download folder.

the solution:

To resolve this issue, you will need to change the permissions for the upload folder and ensure that you are logged in to cPanel and then go to File Manager

After that, go to the Public HTML >> wp content path , then select the Uploads file , right-click on it and choose Change permissions .

Then in the last step, change the permissions to 744 or 755

You can also change the permissions with the same previous steps, but using the FTP program, by logging in to your account, then going to the same path, then selecting the Uploads file , right-clicking on it and choosing Change permissions .

Then change Change Permissions to 744 or 755 and select the options in the image to apply the changes to all files and directories.

Then try to upload the photos again.


4- HTTP error

When you try to upload the image to your site, you may see a problem with HTPP uploading the image without WordPress giving a clear reason for the cause of the problem, as in the following image.

There are many reasons why this error occurs which we will talk about 

4.1- Verify the error

Firstly, sometimes this error appears due to a temporary malfunction or stoppage in the server, so it is necessary to re-download the images after a period of time to ensure that the error appears continuously, and you must also ensure the name of the image, and the absence of distinctive letters or anything else, which may lead to… Sometimes this problem appears.

4.2- Try another browser

Sometimes this problem can be solved by trying another browser. Therefore, it is necessary to try another browser before trying to search for solutions to this problem.

4.3- Stop add-ons

The same applies to add-ons, which sometimes cause problems or errors like this. Therefore, you must also verify the add-ons by trying to disable them and then try to upload the images again.

You can disable add-ons by going to ( Add-ons << Platform Add-ons ) and then selecting all add-ons and disabling them

4.4- Increase the WordPress memory limit

Another common cause of the HTTP error is the lack of memory in WordPress, which can lead to many errors, including this error.

To solve the problem, you must go to the file ( wp-config.php ) and add the following line:

define ('WP_MEMORY_LIMIT'، '256M');

This will increase the PHP memory limit to 256 MB, and the memory we increased here is different from the file size limit increase we talked about at the beginning of the article when we increased the amount of WordPress memory to run applications on the server.

You can increase the memory size by going to the path: File Manager >> Software >> MultiPHP INI Editor

  • Add the line at the top to increase the size via FTP

By accessing the .htaccess file and adding the line

php_value memory_limit 256M

5- Adjust the image processor

When you install WordPress, it comes with image wizards (plugins, libraries) for editing image files. Without these plugins, you won’t even be able to create or edit thumbnails or anything else. These accessories or processors are provided by the service provider, and you will not feel their presence. The system also comes with two image editing wizards (ImageMagick and PHP-GD).

As for the ImageMagick processor, it usually consumes available memory and causes an HTTP error.

You can solve the problem in one of two ways:

The first solution is to make the GD library the default image editor. From within the WordPress control panel, go to the template editor, then to the functions.php file, and add the following code.

function hs_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’, ‘hs_image_editor_default_to_gd’ );

Also you can solve the problem by adding the following code to the htaccess file

SetEnv MAGICK_THREAD_LIMIT 1

6- Other problems that may cause images to be uploaded

There are some other problems, which we will discuss in general. You can learn about them so as not to cause this problem

Verify the website template

Sometimes you may encounter a problem uploading images after installing a new template or updating a previous template. To confirm this, you need to switch to a default template and try uploading images to see if the template is causing the problem.

Check PHP version

Mostly if your WordPress version is lower than 5.2.4, you may encounter this problem. WordPress requires PHP 5.2.4 or higher to run smoothly, and any version older than that may cause problems.

Clear cache

There is a possibility that the HTTP error is caused by the cache, so you should try clearing the browser cache.

Disable mod_security

mod_security is an open source firewall that can cause problems when uploading images, including an HTTP error. So you can try disabling mod_security, and try uploading the images again.

To stop mod_security from working, you need to access the .htaccess file. And add the following code:


SecFilterEngine Off
SecFilterScanPOST Off

You can also access and disable mod_security from within the control panel, then go to the Security section

Image source

Use Browser uploader to upload images

There is another way to upload images through WordPress, which can be tried. It may help in solving the problem of uploading some images. This is from within the WordPress control panel. You must go to the << Add New modes and then choose the location of the image you want to upload.

Add Add From Server

Also one of the additions that can help solve problems related to uploading images is using the Add From Server extension . You upload the files to the web server and then import them into WordPress.

In the end, the problems and errors that appear when uploading images to WordPress are multiple, and you can try any of the previous solutions to address the errors. It is not necessary to do all of these solutions, but what is important is to know what is the cause of the problem in order to choose the most appropriate solution, and often one cause is the one causing the problem and it goes away. The problem with that, but we talked in detail about the various ways to be aware of the most famous reasons for this so that you can avoid them.

Avatar photo
I am a young man who has been working in WordPress and e-marketing for 10 years. I would like to share my experience with you so that we can become professional in WordPress I will be happy to share the experience with you.