Generate Image Sizes On the Fly (Stop Pre-Building 20 Thumbnails per Upload)

Date:

A single upload can quietly spawn twenty or thirty resized copies you’ll never serve. Making each size only when a visitor asks for it trims the bloat without slowing anything down.

The short answer: On-the-fly (OTF) image generation flips WordPress’s default from proactive to reactive: instead of creating every registered thumbnail size the moment you upload, it keeps only the original and generates a specific size the first time a visitor’s page actually requests it, then caches that file for everyone after. You get the same fast, right-sized images with far less disk use, smaller backups, and quicker migrations.

How WordPress handles images by default

WordPress is proactive. Upload one image and the server immediately resizes it into every dimension your theme and plugins have registered – the three core sizes plus whatever a heavy multipurpose theme and its add-ons declare. A single hero image can become fifteen, twenty, or thirty files. Most of those sizes are never actually served to a visitor, yet they all sit on disk, swell every backup, and slow every migration and sync.

Most of the thumbnails WordPress builds on upload are never served – they just sit in every backup you take.

What “on the fly” changes

On-the-fly generation is reactive. The logic is simple:

  1. You upload one high-resolution original. No resized copies are made yet.
  2. A page loads that needs, say, a 300-pixel-wide version for a card on a phone.
  3. The system checks: does that exact size exist? If no, it generates it right then, serves it, and caches it.
  4. Every later visitor who needs that size gets the cached file instantly.

The site ends up storing only the sizes people genuinely request, in the dimensions they’re actually viewed at – not a full matrix of every size something might one day use.

Why it helps performance and SEO

The win isn’t a faster image on any single view – a cached OTF thumbnail serves exactly as fast as a pre-built one. The wins are structural:

  • Less bloat. You store a handful of real sizes instead of dozens of speculative ones, so the uploads folder stays small.
  • Smaller, faster backups and migrations. Fewer files means less to copy, which is where the “server bloat” pain actually bites.
  • Right-sized images for Core Web Vitals. Because sizes are generated to match how images are really requested, a page can serve a tightly-fitted file, which helps Largest Contentful Paint (LCP) – a real Google ranking signal – without shipping oversized images.

On-the-fly doesn’t make the served image faster; it makes everything around it – storage, backups, migrations – lighter.

The trade-off to plan for

The one cost is the first request for a size: that visitor waits for the file to be generated before it’s cached. On a busy page this is invisible, but there are two things to get right. First, make sure the cache is durable and, ideally, sits behind or in front of a CDN, so a generated size is reused widely rather than rebuilt. Second, decide what happens to the original – OTF keeps a high-resolution master, so store it sensibly rather than deleting it, because every future size is derived from it.

When it’s worth switching

On-the-fly generation pays off most on image-heavy sites with themes that register many sizes – exactly the case where the default matrix explodes into dozens of files per upload. A small site with a lean theme and a few registered sizes gains little and can stay on the default. The heavier your theme’s size list and the larger your library, the more the reactive approach saves you in storage and operational drag.

The short version

By default WordPress builds every registered thumbnail size the moment you upload an image, most of which are never served but all of which bloat your disk, backups and migrations. On-the-fly generation instead keeps the original and creates each size only when a visitor first requests it, caching it thereafter. The served image is just as fast, while storage and operations get much lighter. Plan for the one-time cost of generating a size on first request – back it with a durable cache and a CDN – and reach for it when a heavy theme and a large library make the default size matrix unmanageable.

Frequently Asked Questions

Does on-the-fly generation make my images load slower?

No, not for the visitor in the normal case. Once a size has been generated and cached, it serves exactly as fast as a pre-built file. The only wait is the very first request for a given size. Keep that wait rare by putting the cache somewhere durable and, ideally, behind or in front of a CDN, so a size generated once is reused rather than rebuilt.

Do I still keep the original image?

Yes. The high-resolution original is essential, because every on-the-fly size is derived from it. Store the master reliably; deleting it would leave the system with nothing to resize from.

Share post:

Subscribe

Popular

More like this
Related

WooCommerce Search by SKU or ISBN Finds Nothing? It Never Looks There

A shopper types the SKU from your catalog, or the ISBN printed on the back of a book, and gets "No products were found". The product is right there, and the number is on its page. Search simply never reads that part of the product.

Computer Slow but CPU and Memory Look Normal? Check the Handle Count

Chrome takes a minute to open, or doesn't open at all. Every click waits. You open Task Manager expecting to find the culprit, and it tells you everything is fine. Here is the number that isn't, and the fix that takes two minutes.

Kernel-Power 41 Tells You Your PC Restarted, Not Why

Your PC restarts with no blue screen, and the only clue is a critical event saying it didn't shut down cleanly. Here is how to get from that event to a short list of suspects.

Set Up WordPress SMTP Without a Plugin, Even on a Multisite Network

WordPress mail goes out as wordpress@ your domain, from the web server, and lands in spam. An SMTP plugin fixes that. So do about twenty lines of code, and on a network of sites the code can give every site its own mailbox and its own password.