Speed

Image Optimization for WordPress: Sizes, Formats, Compression and Lazy Loading, Step by Step

WordPress image optimization step by step: resize, choose WebP or AVIF, compress, serve srcset sizes, prioritise the LCP image and lazy-load the rest.

Image Optimization for WordPress: Sizes, Formats, Compression and Lazy Loading, Step by Step
On this page
  1. Why images matter so much for speed
  2. Image optimization at a glance
  3. Step 1: Resize before you upload
  4. Step 2: Choose the right format
  5. Step 3: Compress, with one tool
  6. Step 4: Serve responsive sizes with srcset
  7. Step 5: Treat the LCP image differently
  8. Step 6: Lazy-load everything below the fold
  9. Step 7: Set width and height on every image
  10. Step 8: Consider an image CDN
  11. Cleaning up an existing media library
  12. A simple image weight budget
  13. Special cases
  14. Quick check: find your heaviest images
  15. When to get help
  16. FAQs
Key takeaways
  • Resize images to the largest size they are shown at, convert photos to WebP or AVIF and compress them with one tool, so no page ships multi-megabyte photos to phones.
  • Treat the main image at the top of the page differently: never lazy-load it, give it fetchpriority="high" and set its width and height, then lazy-load everything below the fold.
  • Fix an existing site by finding the heaviest images first, bulk-optimising with backups of the originals, and checking that sliders, CSS backgrounds and product galleries are covered too.

To optimize images in WordPress, resize each image to the largest size it is actually displayed at, convert photos to WebP (or AVIF), compress them with one optimization plugin, and let WordPress serve smaller versions to phones through srcset. Then load the main image at the top of the page immediately with fetchpriority="high", lazy-load everything below it, and give every image a width and height so the layout doesn't jump.

Images are usually the heaviest part of a WordPress page, and a single photo straight from a phone can outweigh everything else on it. That is why image compression, resizing and WebP conversion are part of my WordPress speed optimization service. This guide is the full workflow, in the order that makes the biggest difference.

Want to shrink images before uploading? The free image compressor sets quality and max width in your browser and shows the size saved.

Why images matter so much for speed

Image weight affects three things visitors and Google both notice:

  • Largest Contentful Paint (LCP): on most pages the largest element is a hero image or banner, so a heavy or late-loading image directly delays the moment the page looks ready.
  • Mobile data and slower phones: a 3 MB homepage that feels fine on office Wi-Fi is a real wait on a congested 4G connection, and a real cost to anyone on a limited data pack. Website speed on Indian mobile networks covers testing in those conditions.
  • Layout shift (CLS): images without reserved space push text down as they arrive.

Image optimization at a glance

StepWhat to doTools
ResizeMatch the largest size the image is shown atAny image editor, Squoosh, or your phone's export settings
FormatWebP or AVIF for photos, SVG for logos and iconsConverter for Media, ShortPixel, Imagify, EWWW
CompressLossy for photos, checked at full sizeOne optimization plugin, not two
Responsive sizesLet browsers pick a smaller file on phonesWordPress srcset, theme and builder settings
LCP imageLoad first, never lazyfetchpriority="high", preload for CSS backgrounds
Below the foldLazy-loadNative loading="lazy"
DimensionsWidth and height on every imageTheme templates, builder settings
DeliveryOptional image CDN for busy or image-heavy sitesCDN image services, caching plugin features

Step 1: Resize before you upload

If an image never displays wider than 1200 pixels, uploading a 4000-pixel original wastes storage, slows backups and gives every later step more work. Resize to roughly the largest size the image will be shown at, allowing a little extra for sharp high-density screens:

Image roleSensible upload width
Full-width hero or bannerAbout 1600 to 2000 px
Image inside the content columnAbout 1200 px
Cards, team photos, blog thumbnailsAbout 600 to 800 px
WooCommerce product imagesSquare, about 1000 to 1200 px, all the same ratio
Logos and iconsSVG where possible

WordPress scales down very large uploads by default (anything over 2560 pixels) and keeps the original on the server, but it is better not to rely on that. Huge uploads can also fail on cheaper hosting with a vague "HTTP error".

Step 2: Choose the right format

FormatUse it forNotes
WebPPhotos and most graphicsUsually much smaller than JPEG or PNG at similar quality, supported by all current major browsers
AVIFPhotos where you want the smallest filesOften smaller than WebP but slower to create; check your plugin and host support it
JPEGA fallback for photosFine if compressed; WebP or AVIF versions are better
PNGScreenshots or graphics needing exact pixels or transparencyOften very large for photos; lossless WebP is usually smaller
SVGLogos, icons, simple illustrationsTiny and sharp at any size; upload only from trusted sources
GIFAvoid for animationA short MP4 or WebM video is far smaller

Recent WordPress versions accept WebP uploads, and AVIF where the server supports it. To convert an existing library, a plugin such as Converter for Media, ShortPixel, Imagify or EWWW Image Optimizer creates WebP or AVIF copies and serves them to browsers that support them. Feature sets and free limits change, so check each plugin's current plans.

Step 3: Compress, with one tool

Lossy compression removes detail most people never notice and gives much bigger savings than lossless, so it is usually the right choice for photos. Use lossless or a high quality setting for screenshots, images containing text, and product photos where fine detail sells the product. Before bulk-processing the whole library, compare a few faces, product shots and text-heavy images at full size.

The most important rule is to run one image optimization tool. Two plugins compressing the same files, or a plugin and a CDN both converting formats, wastes credits and causes odd, hard-to-trace results. WordPress image compression plugins compared covers ShortPixel, Imagify, EWWW and Smush in detail, including how each delivers WebP.

Step 4: Serve responsive sizes with srcset

Every upload is saved in several sizes, and for images added through the editor WordPress outputs srcset and sizes attributes so a phone can download a 768-pixel version instead of the full 1600-pixel one. That only works when the theme or page builder uses those attributes. Common ways it breaks:

  • Images set as CSS backgrounds in a page builder, which load one size for every screen. Many builders let you set a smaller background image for mobile.
  • Theme templates that output the "full" size image directly.
  • Sliders and galleries that load every slide at full size straight away.

To check, right-click an image on your phone-sized browser window, choose Inspect, and look for srcset in the image tag. In the Network panel, filter by "Img" and sort by size to see what actually downloads.

Step 5: Treat the LCP image differently

The main image at the top of the page should load as early as possible. That means no lazy loading, a hint that it matters most, and dimensions set. In HTML terms, a well-handled hero image looks like this:

<img src="/wp-content/uploads/hero-1600.webp"
     srcset="/wp-content/uploads/hero-800.webp 800w,
             /wp-content/uploads/hero-1200.webp 1200w,
             /wp-content/uploads/hero-1600.webp 1600w"
     sizes="100vw"
     width="1600" height="900"
     fetchpriority="high"
     alt="Rooftop solar panels on a factory in Pune">

Recent WordPress versions try to add fetchpriority="high" to the image they think is the LCP element and skip lazy loading for it, but page builders, sliders and optimization plugins can override that. If the hero is a CSS background, the browser discovers it late, so a preload hint in the page head helps:

<link rel="preload" as="image" href="/wp-content/uploads/hero-1600.webp" fetchpriority="high">

Better still, use a real image element for the hero where your theme allows it. How to fix slow LCP on WordPress shows how to identify the LCP element and which part of its loading is slow.

Step 6: Lazy-load everything below the fold

WordPress adds native loading="lazy" to content images by default, so images further down the page only load as the visitor scrolls towards them. You rarely need a separate lazy-loading plugin, and adding one on top of the native feature can lead to images that never appear or that load twice. Galleries, logo strips, embedded maps and YouTube videos lower on the page benefit most. Lazy loading explained covers videos, iframes and the common mistakes.

Step 7: Set width and height on every image

When an image has width and height attributes (or a CSS aspect ratio), the browser reserves the space before the file arrives, so text doesn't jump as images load. WordPress adds dimensions to images inserted through the editor; custom theme code, logos and builder widgets are where they go missing. How to fix Cumulative Layout Shift covers the other causes of jumping pages.

Step 8: Consider an image CDN

An image CDN resizes, compresses and converts images on the fly and serves them from servers near each visitor. It suits busy stores, image-heavy portfolios and sites with visitors in several countries, and it can replace a compression plugin rather than sit alongside one. For a small brochure site on decent hosting it is usually unnecessary. See what a CDN is and when you need one.

Cleaning up an existing media library

  1. Take a full backup, including the uploads folder.
  2. Find the heaviest images. Run your key pages through PageSpeed Insights. Depending on the Lighthouse version, image issues appear as separate audits such as "Properly size images" and "Serve images in next-gen formats", or grouped under "Improve image delivery". The DevTools Network panel, sorted by size, shows the worst offenders.
  3. Fix the source of oversized uploads, such as a staff member uploading photos straight from a camera, before bulk-processing.
  4. Bulk-optimize with one plugin, keeping backups of the originals so you can re-compress later.
  5. Check what bulk tools miss: CSS background images, slider images, images inside theme folders and logos.
  6. Retest the same pages on mobile, logged out, with caches cleared.

A simple image weight budget

These are rules of thumb rather than standards, but they make it easy to spot a problem:

ImageAim for roughly
Hero or banner image (mobile version)Under 150 to 200 KB
Content imagesUnder 100 KB each
Thumbnails and cardsUnder 30 to 50 KB each
All images on a typical service pageWell under 1 MB in total

Special cases

  • WooCommerce stores: hundreds of product photos at one consistent ratio keep category pages tidy and light, and gallery zoom images should load only when opened. See WooCommerce speed optimization.
  • Elementor and other builders: background images, hidden "desktop only" sections that still download on phones, and image carousels deserve their own check.
  • Sliders: one strong static image is usually faster and works just as well. If you keep a slider, only the first slide should load straight away.
  • Image SEO: descriptive file names and useful alt text help images appear in Google Images and Lens; see the image SEO guide.

Taking your own photos? See how to prepare photos for your website.

Resizing first also prevents a common upload problem: very large photos can make WordPress fail with a vague message, covered in fixing the HTTP error when uploading images.

Quick check: find your heaviest images

Open the page in Chrome, press F12, go to the Network tab, click the Img filter and reload. Click the Size column to sort largest first. Any image over about 200 KB, or one whose natural size (hover over it in the Elements tab) is far bigger than its displayed size, is the first to fix. In PageSpeed Insights, "Improve image delivery" and the LCP element in Diagnostics name the same files.

When to get help

Get help when pages are still heavy after these steps, because the cause may be the theme, plugins, scripts or hosting rather than images alone. WordPress speed optimization finds the real bottleneck, fixes it safely and ends with a before-and-after PageSpeed Insights report. To start, send your website address.

Related fixes: WooCommerce product images the wrong size, shipping not showing at WooCommerce checkout and landing page size and dimensions.

FAQs

What is the best image size for WordPress?

Upload images at roughly the largest width they are displayed at: about 1600 to 2000 pixels for full-width banners, about 1200 pixels for images in the content, and smaller for cards and thumbnails. WordPress creates the smaller sizes for phones automatically.

Should I use WebP or AVIF?

WebP is the safe default: widely supported and much smaller than JPEG. AVIF can be smaller again but takes longer to create and depends on your host and plugin. Many optimization plugins create both and serve whichever the browser supports.

Does WordPress compress images automatically?

Partly. It creates resized copies with moderate compression and scales down very large uploads, but it doesn't compress aggressively, convert existing images to WebP or bulk-optimize an old media library. That is what an optimization plugin or image CDN is for.

Which is the best image optimization plugin for WordPress?

There isn't one best plugin for every site. ShortPixel and Imagify compress in the cloud, EWWW can compress on your own server, and Converter for Media focuses on WebP and AVIF conversion. Pick one that suits your host and library size, and don't run two at once.

Will image optimization reduce quality?

Lossy compression discards some detail, but at sensible settings most visitors can't see the difference. Check a few product photos, faces and images with text at full size before bulk-processing, and keep backups of the originals.

Does image optimisation help SEO?

Indirectly. Lighter images improve loading speed and Core Web Vitals, which are part of Google's page experience signals, and descriptive file names and alt text help images appear in image search.

Need help with your website?

I'm a freelance WordPress developer building fast, SEO-friendly websites since 2020. Tell me what you need and I'll reply with a plan and a fixed quote, usually within 24 hours.

Found this useful? Share it:
Contact

Let's build your next website

Available for freelance projects, agency white-label work and long-term maintenance. Feel free to pass this along to your team or company.

I reply within 24 hours, usually the same day. Your details are emailed to me, then WhatsApp opens so we can chat right away.

Chat now