Skip to content
HOSTIGAN
WordPress

How to optimise images in WordPress (WebP, AVIF, lazy loading)

Make WordPress images smaller without visible quality loss: pick the right width and format, compress, convert to WebP or AVIF, and get lazy loading and LCP right.

Beginner 5 min read Updated November 24, 2026

Images are usually the heaviest part of a WordPress page, and the largest one at the top is often the element that decides your Largest Contentful Paint (LCP). Getting them right is one of the cheapest speed improvements you can make. In this guide you'll learn what WordPress already does for you, how to prepare images before upload, which formats to use, how to convert your existing library, and how to avoid the lazy-loading mistake that quietly hurts LCP.

What WordPress already does with your images

When you upload an image, WordPress does more than store the file:

  • It generates several smaller copies (thumbnail, medium, large and any sizes your theme registers).
  • Images wider than 2,560 px are scaled down automatically, with the original kept as a backup.
  • In your pages it adds srcset and sizes attributes, so a phone downloads a small copy and a large screen gets a bigger one.
  • It writes width and height on the <img> tag, so the browser reserves the space before the image arrives and the layout doesn't jump.
  • It adds loading="lazy" to images further down the page and, in recent versions, fetchpriority="high" to the image it guesses is the LCP element.

What WordPress does not do by default is compress aggressively or convert your JPEGs to modern formats. That part is up to you.

Step-by-step: optimising images

  1. Measure first. Run PageSpeed Insights on a page with images and note LCP, total page weight and recommendations such as "Properly size images".
  2. Find the display width. Inspect your content column in the browser's developer tools. If it is 800 px wide, uploading a 5,000 px photo serves no purpose.
  3. Resize before upload. Export at roughly the display width — about twice that if you want razor-sharp images on high-density screens.
  4. Choose a format (see the table below).
  5. Compress. For photos, a quality of 75–85 is usually indistinguishable from the original. Always check the result at 100 % zoom.
  6. Automate the rest with one optimisation tool, so future uploads are handled for you.
  7. Measure again and compare.

On your own computer, free tools such as Squoosh do this in the browser. If you work with many files, a command-line tool can batch the job:

for f in *.jpg; do
  cwebp -q 80 -resize 1600 0 "$f" -o "${f%.jpg}.webp"
done

Choosing the right format

FormatBest forNotes
JPEGPhotosUniversal support, larger than WebP/AVIF
PNGScreenshots, graphics with sharp edges or transparencyLarge files for photos
WebPPhotos and graphicsTypically 25–35 % smaller than JPEG; supported by all modern browsers
AVIFPhotosOften smaller than WebP; slower to encode and needs server support
SVGLogos and iconsVector, scales perfectly; only upload SVGs from trusted sources

WordPress accepts WebP and AVIF uploads, but whether it can create the smaller sizes from them depends on the image library on the server (Imagick or GD).

Check what your server supports

Go to Tools → Site Health → Info → Media Handling. You'll see which image editor WordPress uses and which formats it supports. If you have SSH access, you can check directly:

php -r 'print_r(array_filter(gd_info()));'
php -r 'if (class_exists("Imagick")) print_r(Imagick::queryFormats("AVIF"));'

On cPanel hosting you can often enable the imagick extension under Select PHP Version → Extensions.

Note: If AVIF uploads fail or produce no thumbnails, the server's image library doesn't support AVIF yet. Stick with WebP until it does.

Converting your existing media library

New uploads are easy to fix. The hundreds of images already in your library need a tool. You have three main options:

  • The Modern Image Formats plugin (from the WordPress performance team) creates WebP or AVIF versions of new uploads using your server's own image library.
  • An optimisation plugin with its own service, such as LiteSpeed Cache's image optimisation, ShortPixel, Imagify or EWWW. These compress and convert in bulk, often off-server, and can restore originals. Read our guide on LiteSpeed Cache if your host runs LiteSpeed.
  • Manual conversion before upload, which gives you full control but doesn't fix old images.

Whichever you choose, take a backup of wp-content/uploads first (here's how) and keep the "keep originals" option switched on until you've checked the results.

Warning: Use one optimisation tool only. Two plugins converting and rewriting the same images is the most common cause of missing or broken images.

Lazy loading and LCP

Lazy loading delays images until the visitor scrolls towards them, which saves bandwidth on long pages. The problem is the image at the very top: if that is lazy-loaded, the browser waits before even requesting it, and LCP gets worse.

  • Let WordPress's own logic handle it — it skips lazy loading on the first content image.
  • Don't add a second lazy-loading plugin or theme option on top.
  • If your hero image is a CSS background, the browser discovers it late. A normal <img> element loads sooner.
  • Check the LCP element in PageSpeed Insights: it should not have loading="lazy".

Common problems and fixes

  • WebP files exist but visitors still get JPEG. Clear the page cache and any CDN cache, and make sure two plugins aren't both rewriting image URLs.
  • "Properly size images" still appears. Your theme might request a size that's too large, or the image was inserted as "Full size". Pick a smaller size in the block settings.
  • Images look blurry. The compression was too aggressive, or the image is being stretched beyond its width. Raise quality slightly or upload a larger source.
  • Thumbnails are missing after a theme change. Regenerate them — back up first:
wp media regenerate --only-missing --yes
  • The uploads folder is huge. Unused files can pile up. Remove them carefully through the media library rather than deleting files in File Manager, because posts may still reference them.

Measuring the result

Compare LCP, total page weight and the image recommendations before and after. Lab data changes immediately; field data in PageSpeed Insights is a 28-day rolling average, so give it a few weeks. If LCP is still slow despite small images, the bottleneck is likely server response — see how to speed up WordPress for the bigger picture.

In short

Upload images at the width they're shown, use WebP (or AVIF where supported), compress to around quality 80, convert the existing library with one tool, and never lazy-load the image at the top of the page. Measure before and after.

Images on Hostigan

Image optimisation is one half of a fast site; a well-maintained WordPress install is the other. Hostigan's WordPress hosting comes with a one-click install and automatic core updates, so you can spend your time on content instead of maintenance.

Frequently asked questions

Roughly the widest size your theme displays them at, often 1,200–1,600 px for content images and up to about 2,000–2,500 px for full-width hero images. WordPress creates the smaller sizes itself.

Next in “WordPress that performs” · 4 of 7What is LiteSpeed Cache, and how do you use it with WordPress?