- Joined
- Sep 3, 2014
- Messages
- 6,230
- Likes
- 13,100
- Degree
- 9
I hate Wordpress now. It's too late for me on this project. But never again.
Most of us care about our storage space. We pay for it, it makes our backups huge, and it's LITTER.
No, I don't want Wordpress generating 4 sizes of each image I upload, compounded by the 3 or 4 extra sizes that the theme requests. Most users are literally hosting about 10 variations of every image they upload.
It's truly insanity.
I clamped down in this before I started this project. I told Wordpress not to create any sizes and in my theme I never demanded any extras. All was well for a couple years.
Just now I found that one of the newer versions of Wordpress has introduced ANOTHER default image size. But check this: You cannot access it from Settings > Media. It's not there, and you'd never know about it unless you happen to go into your recent uploads folder.
It's called Medium-Large and I'm seeing the first instances of it in December 2015. This corresponds with Wordpress version 4.4.
It generates 768 by XX pixel versions of your images for no good reason. That means we have 14 months to clean up. I can't really find out why, and it only seems to happen on certain larger image sizes, and they don't seem interested in explaining themselves.
Needless to say, I'm more than annoyed. Watch your backs. Wordpress is sneaking in all kinds of crap, not telling us about it, and removing the ability to turn it off (like the REST API, which left millions of sites vulnerable to hacking, and they WERE hacked too.)
Solution: Stop Wordpress From Generating Image Sizes
It used to be that you could set the width and height in the Media settings to zero to stop this behavior, as well as removing add_image_size() and set_post_thumbnail_size() references in your functions.php.
But Wordpress is over-reaching again. I think this time it's some excuse about responsive image sizes.
This is one way to temporarily-permanently (because WP will screw us again somehow) remove the generation of these image sizes:
I pulled this from a github page [updated with the newest medium-large size], but there are 100's of similar functions floating around too. This one shows how to add in theme-based sizes (such as with WooCommerce) that you aren't actively using and has some nice comments to help explain.
The question then becomes "Do I have to manually hunt through all of this crap?"...
I've seen some plugins that will index your images and see if there's meta-data attaching them to specific posts, but depending on how you upload them (in the post editor or in the media center) it may or may not be attached. So you could screw yourself on that.
There's word that some of these plugins that regenerate thumbnail sizes will remove image sizes created by those once you've deleted them. You may want to test that.
In my case, it's 14 months total so I'm going to do it by hand.
As always, take a backup first before you do anything automated like these plugins will.
Most of us care about our storage space. We pay for it, it makes our backups huge, and it's LITTER.
No, I don't want Wordpress generating 4 sizes of each image I upload, compounded by the 3 or 4 extra sizes that the theme requests. Most users are literally hosting about 10 variations of every image they upload.
It's truly insanity.
I clamped down in this before I started this project. I told Wordpress not to create any sizes and in my theme I never demanded any extras. All was well for a couple years.
Just now I found that one of the newer versions of Wordpress has introduced ANOTHER default image size. But check this: You cannot access it from Settings > Media. It's not there, and you'd never know about it unless you happen to go into your recent uploads folder.
It's called Medium-Large and I'm seeing the first instances of it in December 2015. This corresponds with Wordpress version 4.4.
It generates 768 by XX pixel versions of your images for no good reason. That means we have 14 months to clean up. I can't really find out why, and it only seems to happen on certain larger image sizes, and they don't seem interested in explaining themselves.
Needless to say, I'm more than annoyed. Watch your backs. Wordpress is sneaking in all kinds of crap, not telling us about it, and removing the ability to turn it off (like the REST API, which left millions of sites vulnerable to hacking, and they WERE hacked too.)
Solution: Stop Wordpress From Generating Image Sizes
It used to be that you could set the width and height in the Media settings to zero to stop this behavior, as well as removing add_image_size() and set_post_thumbnail_size() references in your functions.php.
But Wordpress is over-reaching again. I think this time it's some excuse about responsive image sizes.
This is one way to temporarily-permanently (because WP will screw us again somehow) remove the generation of these image sizes:
PHP:
<?php
/*
* Custom filter to remove default image sizes from WordPress.
*/
/* Add the following code in the theme's functions.php and disable any unset function as required */
function remove_default_image_sizes( $sizes ) {
/* Default WordPress */
unset( $sizes[ 'thumbnail' ]); // Remove Thumbnail (150 x 150 hard cropped)
unset( $sizes[ 'medium' ]); // Remove Medium resolution (300 x 300 max height 300px)
unset( $sizes[ 'medium_large' ]); // Remove Medium Large (added in WP 4.4) resolution (768 x 0 infinite height)
unset( $sizes[ 'large' ]); // Remove Large resolution (1024 x 1024 max height 1024px)
/* With WooCommerce */
unset( $sizes[ 'shop_thumbnail' ]); // Remove Shop thumbnail (180 x 180 hard cropped)
unset( $sizes[ 'shop_catalog' ]); // Remove Shop catalog (300 x 300 hard cropped)
unset( $sizes[ 'shop_single' ]); // Shop single (600 x 600 hard cropped)
return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'remove_default_image_sizes' );
?>
I pulled this from a github page [updated with the newest medium-large size], but there are 100's of similar functions floating around too. This one shows how to add in theme-based sizes (such as with WooCommerce) that you aren't actively using and has some nice comments to help explain.
The question then becomes "Do I have to manually hunt through all of this crap?"...
I've seen some plugins that will index your images and see if there's meta-data attaching them to specific posts, but depending on how you upload them (in the post editor or in the media center) it may or may not be attached. So you could screw yourself on that.
There's word that some of these plugins that regenerate thumbnail sizes will remove image sizes created by those once you've deleted them. You may want to test that.
In my case, it's 14 months total so I'm going to do it by hand.
As always, take a backup first before you do anything automated like these plugins will.