Recently, one of our users asked us how they can upload large images in WordPress. This is a common challenge for those who want to enhance their website with high-resolution photos.
However, many users see a frustrating error message when trying to upload larger images in WordPress. This is due to the file size limit. Luckily, we know how to easily solve this issue.
In this article, we’ll show you how to fix the large file size error and upload large images in WordPress.
Why You Cannot Upload Large Images in WordPress?
Your WordPress hosting provider may have configured their servers in a way that place a reasonable limit on file upload sizes.
You can see this limit by visiting Media » Add New page.
If the limit is lower than the file you are trying to upload, then you will see an error like this: ‘ filename.jpg exceeds the maximum upload size for this site’.
Another issue which may stop you from uploading large image files is memory limit.
By default, your WordPress site is allowed to use a reasonable amount of memory. When a script runs for too long and exhausts the defined memory limit, then you will see an error.
If you’re encountering either of these errors, then this article will help you fix that so you can easily upload large files to WordPress.
Fixing Image Upload Size in WordPress
If you want to upload large image and media files in WordPress, then here is how you will fix image upload size issue in WordPress.
This method requires you to add code in WordPress. If you haven’t done that before, see this guide on how to paste snippets in WordPress.
Simply add this code in your theme’s functions.php file or in a code snippets plugin.
1 2 3 4 |
<span style="font-size: 115%; color: #000000;">@ini_set( 'upload_max_size' , '64M' ); @ini_set( 'post_max_size', '64M'); @ini_set( 'max_execution_time', '300' ); </span> |
We recommend adding this code using WPCode, the best WordPress code snippets plugin. It makes it safe and easy to add code in WordPress, without editing your theme’s functions.php file.
To get started, you need to install and activate the free WPCode plugin. For instructions, see this tutorial on how to install a WordPress plugin.
Once the plugin is activated, go to the Code Snippets » + Add Snippet page from your WordPress dashboard.
From there, click the ‘Use Snippet’ button under the ‘Add Your Custom Code (New Snippet)’ option.
Next, add a title for your code and paste the code snippet from above into the ‘Code Preview’ box. Don’t forget to select ‘PHP Snippet’ as the code type from the dropdown menu on the right side of the screen.
Finally, simply switch the toggle from ‘Inactive’ to ‘Active’ and click the ‘Save Snippet’ button.
This code tries to increase upload maximum file size, post maximum size, and maximum execution time limits for your WordPress site. However, this may not work for some WordPress websites.
In that case, you can try adding this code to your .htaccess file in your site’s root folder.
1 2 3 4 5 |
<span style="font-size: 115%; color: #000000;">php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300 </span> |
If both of these methods fail, then you can try adjusting these values using php.ini file.
The php.ini file is a configuration file used by PHP to define settings. Users on shared hosting, typically don’t have access to the main file. However, you can still create an empty php.ini in your site’s root folder using an FTP client.
Simply add this code in your php.ini file:
1 2 3 4 |
<span style="font-size: 115%; color: #000000;">upload_max_filesize = 64M post_max_size = 64M max_execution_time = 300 </span> |
Take a look at our guide on how to increase maximum file upload size in WordPress for more information.
Do You Really Need to Upload Large Image Files in WordPress?
Images take more time to load than text. This means that if you have large images files, then it would take longer for your website to load.
Search engines don’t like slow websites, and your pages with huge images may not rank high in search results. This would cost you traffic and affect your business goals.
We understand many photography site owners may want to upload high quality images to their site. However, high quality images can be optimized to have reasonable file sizes without losing too much quality.
First we would recommend you to learn how to optimize images for web. You can reduce image file size without having to compromise on quality. You can also bulk resize images from within your WordPress admin area.
Next, you should start using Envira Gallery to display images on your website. Envira beautifully displays image galleries without making your website slow. It is incredibly fast, beautiful, and works on all devices. We believe it’s the best photo gallery plugin for WordPress.
Many popular websites rely on CDN’s to serve static content like images. CDN (content delivery network) serves your images from servers located all over the world. This makes your images and rest of your website load simultaneously. It also improves your site’s SEO and user experience.
See our guide on how to install and setup WordPress CDN solution for detailed instructions.
That’s all, we hope this guide helped you learn how to upload large images in WordPress. You may also want to see our guide on how to resize and make images larger without losing quality and our picks of the best drag and drop WordPress page builders.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.