Wordpress is Generating Images Automatically Again.

Ryuzaki

お前はもう死んでいる
Moderator
BuSo Pro
Digital Strategist
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.

Q122KZt.png

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.
 
It would be amazing if Wordpress just had "Wordpress core"...

It would be fully supported, 100% secure, lightweight/bare bones, etc. The only changes were be: Code optimization and security improvements.

Imagine if then.. You could pick out new features like email sub boxes, emjois, video players, this and that, and so on...

Oh wait..

That's what plugins were for! :surprised: (Not version updates)

Getting REAL tried of these core changes personally. Who in the world says:

"Yeah, let's remove the option to stop thumbnails from being generated and the size too..."


- Evil laugh heard from WP HQ.
 
Thanks for the info and the code. I agree that a 'core' version would be AMAZING.

The biggest issue personally is how reliant I am on the damn CMS. What other options are out there that are well enough supported or is it time to really learn how to code and build everything by hand?
 
Thanks for the info and the code. I agree that a 'core' version would be AMAZING.

The biggest issue personally is how reliant I am on the damn CMS. What other options are out there that are well enough supported or is it time to really learn how to code and build everything by hand?

I personally like Drupal. I know it's a resource hog but you can just install core, utilize Drush and put in only what you need.
 
What other options are out there that are well enough supported or is it time to really learn how to code and build everything by hand?

Two I really like so far are:

Perch (https://grabaperch.com/): They aren't exaggerating when they say you can just quickly add it to any HTML template you designed/bought. It's written in PHP but you don't need to know any - just how their tags and template pages work. It's not the prettiest back end if you're working on it for clients, but it's powerful despite the simplicity and you can make pages that are made up of multiple reorderable components etc. We've used this one on a production site for a client already and are really pleased with the result.

Wagtail (https://wagtail.io/): Based on Django so you will need to learn to code a bit in Python (not much if you just want to get a basic site up and running but you'll want to familiarise yourself with Python and Django first). Really beautiful admin area, and tons of flexibility to do exactly what you want. Forget about features being forced on you automatically your blog doesn't even need to have simple features like tags etc unless you specifically turn them on. We're building something on this currently.

Another contender:

Grav CMS (https://getgrav.org/): A flat file CMS so speed and simplicity are core features. I haven't built a production site on it yet but you don't need to learn to code, just learn the templating system they use and you're good to go. A slight learning curve compared to WP but fast, easy enough to get into, and a very nice back end for those of you building for clients.
 
Back