opened image

How to allow images larger than 2560 pixels to be uploaded in WordPress

Since version 5.3, WordPress has limited the maximum size of uploaded images to 2560 pixels. This was done to improve site performance and reduce server load.

As a result, we can observe the following errors:

 

 

If you want to allow files larger than 2560 pixels to be uploaded, you can use one of the following methods:

Changing parameters in the functions.php file:

Add the following code to your theme's functions.php file:

 

function custom_image_size_limit( $size ) {

return 5242880; // 5 MB in bytes

}

add_filter( 'upload_size_limit', 'custom_image_size_limit' );

 

 

This will increase the maximum file upload size to 5MB.

 

Changing parameters in the .htaccess file:

 

If you are using an Apache server, you can add the following code to your .htaccess file:

 

php_value upload_max_filesize 10M

php_value post_max_size 10M

php_value max_execution_time 300

php_value max_input_time 300

 

 

This will increase the maximum file upload size to 10MB.

 

Changing parameters in php.ini file:

 

If you have access to the php.ini file on the server, you can add the following lines:

 

upload_max_filesize = 10M

post_max_size = 10M

max_execution_time = 300

max_input_time = 300

 

This will increase the maximum file upload size to 10MB.

Please note that changing the settings may not be safe, as increasing the maximum file size may overload the server. Also, if you do not know how to do it correctly, then it is better to contact an experienced specialist.

 

If your site is running on PHP CGI

If your site is running PHP CGI, then you can change the settings in the .htaccess file to allow files larger than 2560px to be uploaded. To do this, you need to create a .htaccess file in the root directory of your site (if it already exists, then open it for editing) and add the following lines:

 

<IfModule mod_php5.c>

php_value upload_max_filesize 10M

php_value post_max_size 10M

php_value max_execution_time 300

php_value max_input_time 300

</IfModule>

 

 

If your server is using later versions of PHP, then change mod_php5.c to the appropriate version (e.g. mod_php7.c).

 

<IfModule mod_php7.c>

php_value upload_max_filesize 10M

php_value post_max_size 10M

php_value max_execution_time 300

php_value max_input_time 300

</IfModule>

 

 

This will increase the maximum file upload size to 10MB and set the maximum script execution time to 300 seconds.

If after this change you continue to get an error when uploading files, then you may need to change the PHP settings directly in php.ini or contact technical support for further assistance.

The settings in the cgi.conf file are configured for the Apache server, which uses the FCGI (FastCGI) module to process scripts in PHP and other programming languages. In particular, the FcgidConnectTimeout and FcgidMaxRequestLen parameters are responsible for the following:

  • FcgidConnectTimeout: This setting specifies the timeout the server should spend establishing a connection with a FastCGI process (eg PHP-FPM). The default value is 20 seconds.
  • FcgidMaxRequestLen: This parameter specifies the maximum request size that can be processed by the server. The default value is 131072 bytes (128 kilobytes). If your server frequently handles large requests (for example, downloading large files), then you can increase the value of this parameter to 32000000 (32 megabytes).

Both settings can be configured to suit your site's needs, however changing these settings can affect your server's performance and, in some cases, can result in server overload.

What other options in the apache fastcgi and php config files can affect the loading of images larger than 2560px?

There are several options in Apache, FastCGI and PHP configuration files that can affect the loading of images larger than 2560 pixels. Some of these options include:

  • upload_max_filesize: This setting specifies the maximum file size that can be uploaded to the server. If the file size exceeds this value, the download will be rejected. You can set the value of this parameter in the PHP configuration file (eg php.ini) according to the requirements of your site. By default, this value is 2M (2 megabytes).
  • post_max_size: This setting specifies the maximum size of data that can be sent via the POST method to the server. This may include uploaded files and other forms of data. If the value of this parameter is less than upload_max_filesize, then file uploads may be rejected. By default, this value is also 2M (2 megabytes).
  • MaxRequestLen: This setting specifies the maximum request size that can be processed by Apache. If the request exceeds this value, the server will return a 413 error. You can set the value of this parameter in the Apache configuration file (for example, httpd.conf) according to the requirements of your site.
  • Timeout: This setting specifies the timeout for requests to the server. If the file download takes longer than the value set for this parameter, the connection will be terminated. You can set the value of this parameter in the Apache config file or in the PHP-FPM config file (if applicable) as required by your site.

In general, optimal server and PHP and Apache settings can help ensure that files on your site load quickly and reliably, including images larger than 2560 pixels.

We also suggest you other useful articles: