WordPress · Performance

How to Optimize Images for WordPress Blog Posts

8 min readWordPressPerformanceBy The Digital Penguin

Oversized images are the most common reason WordPress blogs load slowly. Here is how to fix them — with plugins, settings, and a little code.

How to fix images for blog posts using code in WordPress

Images make blog posts readable, shareable, and engaging — and they're also, on most WordPress sites, the single biggest performance problem. Every oversized photo slows your load time, which hurts user experience, conversions, and your Google rankings all at once. The good news: image optimization is very fixable. Here's the complete checklist.

Why image optimization matters

  • Speed: images typically account for half or more of a page's total weight. Shrink them and the whole page gets faster.
  • SEO: page speed is a ranking factor, and optimized images with good alt text can also rank in Google Images — a traffic source most sites ignore.
  • User experience: visitors on mobile data won't wait for a 4 MB hero photo. They'll leave.

1. Resize before you upload

The most common mistake is uploading photos straight from a camera or phone — often 4000+ pixels wide — into a blog column that displays at 800px. Resize images to roughly the maximum size they'll actually display (for most blog layouts, 1200–1600px wide is plenty) before uploading.

2. Choose the right format

  • JPEG — photos and complex images. Best balance of quality and size.
  • PNG — screenshots, logos, and anything needing transparency. Larger files, so use only when needed.
  • WebP — the modern format, typically 25–35% smaller than JPEG at the same quality. WordPress has supported WebP uploads since version 5.8.
  • SVG — icons and simple graphics. Infinitely scalable, tiny file size (requires a plugin to enable safely).

3. Compress — automatically

Compression plugins optimize every image on upload and can bulk-optimize your existing media library. Reliable options include Smush, ShortPixel, Imagify, and EWWW Image Optimizer. Most can also convert images to WebP automatically. Set it once, and every future upload is handled.

4. Use lazy loading

Lazy loading delays loading images until the visitor actually scrolls near them, which dramatically speeds up the initial page view. WordPress adds this automatically now, but you can control it per image in your theme or HTML:

<img src="chart.webp" alt="Organic traffic growth chart"
     loading="lazy" width="800" height="450">

5. Always set width and height

When an image has no declared dimensions, the browser doesn't know how much space to reserve — so the page "jumps" as images load. That jump is Cumulative Layout Shift (CLS), one of Google's Core Web Vitals. Declaring width and height (as in the snippet above) fixes it, and this CSS keeps images responsive inside your content column:

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 8px;
}

6. Let WordPress serve responsive sizes

WordPress automatically generates several sizes of each upload and uses srcset so phones get small versions and desktops get large ones. You can add your own size for your theme's content width in functions.php:

add_image_size( 'blog-content', 1200, 0, false );

Then regenerate thumbnails (with a plugin like Regenerate Thumbnails) so older uploads get the new size too.

7. Don't forget alt text and file names

Name files descriptively before uploading (wordpress-image-optimization-checklist.webp, not IMG_8843.jpg) and write alt text that describes what the image shows. It's an accessibility requirement, and it's how your images earn rankings in Google Images.

Quick checklist: resize to display size → pick JPEG/WebP → compress with a plugin → lazy load → set width/height → descriptive file name → alt text. Do these seven things and images stop being your speed problem.

The bottom line

Image optimization is one of the highest-return fixes in WordPress: an afternoon of setup that makes every page faster forever. If you'd rather have us audit and speed up your whole site — images, caching, hosting, and all — our website development and SEO teams do exactly that.

Let's build something

Would you like to start a project with us?

Contact us now and tell us what you're working on. We'll come back with a clear plan and a quote — no pressure, no jargon.

Get a Free Quote