Recently, a user approached us with a query on how to upload large images in WordPress. It’s a common issue faced by many users who encounter an error while attempting to upload bigger images, which is primarily due to the file size limit.
In this article, we will guide you on how to resolve this problem and successfully upload large images in WordPress.
Why Uploading Large Images in WordPress is Not Possible?
It is possible that your WordPress hosting provider has set up their servers to restrict the size of file uploads.
To check this limit, navigate to the Media » Add New page.
If the file you are trying to upload exceeds this limit, you will receive an error message that says something like ‘filename.jpg exceeds the maximum upload size for this site’.
Another issue that can prevent you from uploading large image files is the memory limit. By default, your WordPress site is permitted to use a reasonable amount of memory. However, if a script runs for too long and uses up the defined memory limit, you will receive an error message.
If you are experiencing either of these errors, this article will assist you in resolving the issue so that you can easily upload large files to WordPress.
Resolving Image Upload Size Issues in WordPress
To resolve the image upload size problem in WordPress and enable the uploading of large image and media files, you can follow these steps.
Firstly, you need to insert code into WordPress. If you are unfamiliar with this process, refer to this guide on how to paste snippets in WordPress.
Next, add the following code to your theme’s functions.php file or a code snippets plugin.
@ini_set( ‘upload_max_size’, ’64M’);
@ini_set( ‘post_max_size’, ’64M’);
@ini_set( ‘max_execution_time’, ‘300’);
Our recommendation is to utilize WPCode, the top-rated WordPress code snippets plugin, for adding this code. This plugin ensures a secure and effortless way to integrate code in WordPress, without the need to modify your theme’s functions.php file.
To begin, you must first install and activate the WPCode plugin, which is available for free. If you need assistance with this process, refer to a tutorial on how to install a WordPress plugin.
After activating the plugin, navigate to the Code Snippets » + Add Snippet page in your WordPress dashboard.
Next, select the ‘Add Your Custom Code (New Snippet)’ option and click the ‘Use Snippet’ button.
Afterwards, provide a title for your code and paste the code snippet from above into the ‘Code Preview’ box. Remember to choose ‘PHP Snippet’ as the code type from the dropdown menu located on the right-hand side of the screen.
To activate the snippet, toggle the switch from ‘Inactive’ to ‘Active’ and then click the ‘Save Snippet’ button.
This piece of code attempts to enhance the maximum upload file size, post size, and execution time limits for your WordPress website. Nevertheless, it may not be effective for certain WordPress sites.
If this is the case, you can consider appending this code to your .htaccess file located in the root directory of your website.
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
If the aforementioned approaches do not work, you can attempt to modify these values by editing the php.ini file.
The php.ini file is a configuration file utilized by PHP to establish settings. Shared hosting users usually lack access to the primary file. Nevertheless, you can still generate an empty php.ini in your site’s root folder by using an FTP client.
To add this code to your php.ini file, simply follow these steps:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
Is it necessary to upload large image files in WordPress?
Images take longer to load than text, which means that if you have large image files, your website will take longer to load. Slow websites are not favored by search engines, and pages with huge images may not rank high in search results, which can negatively impact your website traffic and business goals.
We understand that many photography site owners want to upload high-quality images to their site. However, high-quality images can be optimized to have reasonable file sizes without compromising on quality. We recommend learning how to optimize images for the web and bulk resizing images from within your WordPress admin area.
To display images on your website, we suggest using Envira Gallery. Envira Gallery beautifully displays image galleries without slowing down your website. It is fast, visually appealing, and works on all devices. We believe it is the best photo gallery plugin for WordPress.
Many popular websites use content delivery networks (CDNs) to serve static content like images. CDNs serve your images from servers located all over the world, which allows your images and the rest of your website to load simultaneously. This improves your site’s SEO and user experience.