By default, WordPress generates three sizes for each image you upload. Themes and plugins can generate additional image sizes which can easily push the number between 5 and 10. If you have a lot of image based content on your site, after a while this can increase your storage needs and size. of the backup file. In this article, we will show you how to prevent WordPress from generating image sizes.
The first thing to keep in mind is that the default image sizes are not harmful to your website. Most WordPress hosting providers offer generous enough disk space to store thousands of images.
Additional image sizes are generated and stored during the upload process, so they do not affect website visitors in any way. If you're having trouble handling images or posting thumbnails, instead of turning them off, you can learn how to solve some common image problems.
That said, some users may want to prevent WordPress from generating image sizes. For example, if you have thousands of images, then copies of these images could make your backup sizes extremely large. It would also take a lot of time for your backup plugin to prepare and store backups in the cloud. Lastly, if you don't see yourself using some of the available image sizes, disabling them will save space.
You first need to understand how many copies of an uploaded image are generated by WordPress. By default WordPress generates three image sizes, for thumbnail, medium and large. In addition to these image sizes, your WordPress theme can also have its own image sizes for featured image/post thumbnails, sliders, and other features.
You need to connect to your website using an FTP client to find out how many copies of an image your WordPress site is generating.
Start by uploading an image to your site from the WordPress admin area. Next, connect to your website using an FTP client or use cPanel's file manager. Now go to / wp-content / uploads /
directory. The image file you upload is stored in a directory based on the year and month. Once you are in the directory, you will see all the images generated by WordPress.
As you can see in the screenshot above, our WordPress demo installation is generating 5 copies of each image. Three of these images are the default WordPress image sizes:thumbnail, medium, and large. Two other sizes are generated by the theme.
You can prevent WordPress from generating default image sizes by visiting Settings »Media In the WordPress admin area. There you will see the default image sizes predefined by WordPress. You need to set these sizes to 0 which will prevent WordPress from generating default image sizes when you upload a new image.
Note:WordPress uses thumbnail image size for galleries, so if you set it to 0, your future gallery display may not work properly.
The other two image sizes are generated by the WordPress theme. You can usually find the theme size code in your theme's functions.php file. Just find the line of code that contains add_image_size
function. It will look something like this, and there could be multiple lines depending on how many image sizes your theme supports:
add_image_size ('homepage-thumb', 220, 180, true);
Removing these lines will prevent your theme from generating those image sizes.
You also need to find the line that contains set_post_thumbnail_size
function. It will look something like this:
set_post_thumbnail_size (150, 150);
Removing this line will prevent the theme from generating the post thumbnail size in WordPress.
Note that the theme may use these image sizes for post thumbnails, sliders, attachments, or custom post types. Only remove them if you are sure and aware of the effect this could have on your site.
We hope this article has helped you prevent WordPress from generating image sizes and keep your upload directory clutter-free. For comments and questions, you can leave a comment below, or join us on Twitter and Google+.