How to Prevent WordPress from Auto-Cropping Your Images
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:
- Your theme or page builder handles image sizing on its own, so WordPress generating extra sizes is unnecessary.
- You upload high-resolution images and want them served at their original dimensions without any resizing.
- Your server storage is limited and you want to stop new image sizes from being generated going forward.
- You’re running a photography or portfolio site where preserving the original image quality is more important than automated crops.
- You’ve noticed distorted or incorrectly cropped images on the front end and want WordPress to stop interfering.
- You manage a site with a large media library and want to reduce the number of files added with each upload.
When to Avoid This
Skip this snippet if your site depends on any of these:
- Your theme relies on specific image sizes like thumbnail, medium, or large to display images correctly in listings or headers.
- You use WooCommerce, which generates its own product image sizes. Removing those sizes can break product image display.
- Your page builder or gallery plugin pulls registered image sizes to render layouts. Those layouts may break without them.
- You use lazy loading or responsive images that depend on srcset attributes, which WordPress builds from intermediate image sizes.
- Your site displays featured images in posts or archives. Those areas often rely on a cropped thumbnail size.
- You have an existing media library with images already processed. This snippet only affects new uploads, not images already on your site.
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:
- Add it to your child theme’s functions.php file or a code snippet plugin.
- Paste the code and save the changes.
- 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.