Skip to content
Insights

Lighter websites

WordPress Image Sizes, srcset and the Big-Image Limit

WordPress makes smaller copies of every photo and offers them to phones, but only in some cases. Here is how to check which file a phone actually gets.

Sol Rudd6 min read

Diagram: an uploaded camera photo becomes a scaled copy (if over 2560px), Large, Medium and Thumbnail copies; a phone given an img with srcset gets a small copy, while a CSS background or custom HTML image sends the big file

Most small business photos come straight off a phone or a photographer's camera, thousands of pixels wide. A phone screen needs far fewer. WordPress has handled this for years: it makes smaller copies when you upload and, in the right conditions, lets the browser pick the one that fits. The catch is “in the right conditions”. Images added in other ways can skip all of it, and then a phone downloads the largest file on offer.

This article explains what WordPress does by itself, how to see which file a phone really receives, and what to ask for if it is the big one.

What WordPress does when you upload a photo

Two things happen. First, WordPress creates image sub-sizes: resized copies of the original. Some of their maximum dimensions are set under Settings > Media, where the Thumbnail, Medium and Large sizes are listed in pixels. Your theme may register more.

Second, since WordPress 5.3, very large photos are scaled down. The core developer note says “The default threshold value is 2560px”: if a photo's width or height is above it, a copy is made with 2,560 pixels as the maximum width and height. The original is still stored in the uploads folder, and developers can find it with wp_get_original_image_path(), so nothing is lost if you need the full file later. WordPress adds “-scaled” to the copy's file name, such as my_image-scaled.jpg, and the code reference says this scaled copy is then used as the largest available size. A developer can change the limit with the big_image_size_threshold filter, or turn it off by returning false.

So the big-image limit is a safety net, not a mobile fix. A 2,560-pixel photo is still far wider than a phone needs. What sends phones a smaller file is srcset.

When WordPress adds srcset for you

The WordPress responsive images documentation says native responsive images have been supported since WordPress 4.4. Two routes add them:

  • Theme templates that output images with wp_get_attachment_image(), which generates srcset and sizes from the image's stored sizes.
  • Images in post and page content. wp_filter_content_tags() adds the attributes when the page is shown, but only to img tags that carry a wp-image-123 style class linking them to a Media Library item.

By default the sizes value tells the browser the image is full screen width up to its own width, and copies wider than 2,048 pixels are left out of srcset. The documentation also notes that WordPress leaves srcset and sizes alone if the HTML already has them. How the browser then chooses a file is covered in why desktop and mobile results differ.

Check which file a phone downloads

  • Open the page in Chrome, press F12 and click Toggle device toolbar. Pick a phone from the Dimensions list. Chrome calls this a “first-order approximation” of a real phone, which is enough here.
  • In the Network panel, tick Disable cache. MDN suggests this so Chrome doesn't reuse a larger image it already downloaded. Click Img and reload.
  • Look at the file names and sizes. A name ending in -scaled, or an original you recognise from your camera, means the phone is getting the biggest copy.
  • To check one image, right-click it, choose Inspect, then type $0.currentSrc in the Console. $0 is the element you just selected, and currentSrc is the address of the file the browser selected from srcset. If the tag has no srcset at all, you have found the problem.

Why a phone might still get the big file

  • The image is a CSS background. Page builder sections and hero banners can set a photo as a background. srcset belongs to the img element, so WordPress's automatic handling doesn't reach it; smaller versions have to be handled in the CSS instead. See also hero banners and sliders.
  • Custom HTML or a pasted address. An image typed into a Custom HTML block, or added by URL, usually lacks the wp-image class, so no srcset is added.
  • A builder or theme writes its own tag pointing at the full-size file, without srcset.
  • Very large uploads with the limit turned off. If a developer disabled the threshold, the largest copy may be the camera original.

What is it worth? As an illustrative example, if a phone gets a 1.5 MB photo where a 200 kB copy would do, that is 1.3 MB extra, about 0.19 g CO₂e per view at GreenTracer's Sustainable Web Design Model v4 figure of 0.148 g per MB. A GreenTracer check uses the heavier of its mobile and desktop runs, so a phone-only fix shows in the estimate only if mobile was the heavier run. Resizing and compressing originals before upload helps both; see image weight and choosing image formats.

What to ask your developer

  • Which images on our main pages have no srcset, and why?
  • Can background images in the builder sections have smaller versions for phones?
  • Is big_image_size_threshold changed or disabled anywhere, and is there a reason?
  • Do the sizes values match how wide the images really display?
  • Do images further down the page get a loading attribute? WordPress adds one to content images through the same wp_filter_content_tags() step, but images output another way may miss it.

After any change, check the page again so the report shows the new weight.

Sources

All articles

Check your own site

See the estimated carbon of one page view on your page, its grade, and whether your host is listed as green. It's free.

Check a website