Do you have ever experienced that you have uploaded an image to your WordPress site and it automatically cropped in different sizes? If so, read on…
When we upload an image, WordPress automatically generates three additional sizes for that. Our installed themes and plugins can generate more additional sizes also.
Let’s check…
Log in to Hosting panel > File Manager > [Domain root directory] > wp-content > uploads
WordPress does it for appearing the right size images to the right places (thumbnail, feature, etc.). But modern themes can handle this without cutting your photos.
And more images mean more storage – more backup time. If you want to get rid of this, simply follow my next steps.
Disable WordPress Default Image Cropping
You can stop WordPress from generating extra image sizes following below steps:
- Log in to your WordPress Dashboard
- Go to Settings > Media
- Set the value 0 for all media sizes
- Save changes
Stop Image Cropping For Themes & Plugins
If you want to prevent your theme and plugins from creating additional image sizes, you can do it by adding the following line of code:
function bloggerzia_disable_crop( $enable, $orig_w, $orig_h, $dest_w, $dest_h, $crop )
{
return false;
}
function bloggerzia_disable_extra_image_sizes() {
foreach ( get_intermediate_image_sizes() as $size ) {
remove_image_size( $size );
}
}
add_action( 'init', 'bloggerzia_disable_extra_image_sizes' );
add_filter( 'image_resize_dimensions', 'bloggerzia_disable_crop', 10, 6 );
You can add this code in two methods:
Method #1: Editing functions.php file
Never edit the files of your main theme. Instead, you should use a child theme.
Usually, a child theme is given along with the main theme. If you don’t have one, you can ask the theme vendor. Or you can do Google. Hopefully, you’ll get one.
Now follow the steps below:
- Log in to your Hosting Panel
- Go to the File Manager
- Go to the Root Directory of your domain
- Enter your wp-content folder
- Go to themes > [child_theme_folder]
- Select the functions.php file and Edit
Now add the above code at the bottom here.
Method #2: Using plugin
If you think the previous method is not suitable for you. Then you can follow this method.
- Log in to your WordPress Dashboard
- Go to Plugins > Add New
- Search code snippets
- Install and activate the Code Snippets plugin.
This plugin is developed by Code Snippets Pro. Now follow the steps below:
- From left menu, go to Snippets > Add New
- Give a name of this snippets [could be any name]
- Enter the given code into the Code section
- Now click on Save Changes and Activate
Congratulations! You’re all done.
Read: Bramework Review