Skip to content
Blogger Zia

How to Prevent WordPress from Auto-Cropping Your Images

Category: Code Snippets

WordPress generates several resized versions of every image you upload.

Those extra files build up fast, eat into your storage, and slow down your backups over time.

In this post, I’ve shared a code snippet that stops WordPress from cropping and resizing images automatically.

If you run a photography site, a portfolio, or any site where image quality matters more than automated sizing, this one’s for you.

When to Use This

Add this snippet if any of these situations match your setup:

When to Avoid This

Skip this snippet if your site depends on any of these:

The Code Snippet

// ==========================================================
// DISABLE IMAGE CORPPING
// ==========================================================

// Disable all auto-generated intermediate image sizes
add_filter('intermediate_image_sizes_advanced', '__return_empty_array');

// Disable big image scaling (no 2560px limit)
add_filter('big_image_size_threshold', '__return_false');

// Disable cropping/resizing
add_filter('image_resize_dimensions', '__return_false');

How to Add This Code Snippet

Follow these steps to add the snippet to your site:

  1. Add it to your child theme’s functions.php file or a code snippet plugin.
  2. Paste the code and save the changes.
  3. Test the change on a staging site before using it on your live site.

Note: Use a child theme or a code snippet plugin. Avoid editing core files. Test on a staging site before going live. This snippet may not work with all themes or plugins.