WordPress can create several sizes of the same uploaded image and send the browser a list of choices with srcset. That is the easy part. The harder part is making sure the browser understands how wide the image will actually appear. That is what the sizes attribute is for.
When responsive image markup is wrong, a phone can still download a large desktop-size file even though WordPress created smaller copies. The fix is not always stronger compression. First make sure the browser is choosing the right source.
What srcset does in WordPress
When you upload an image, WordPress normally creates several intermediate sizes. Themes and plugins can create more. When WordPress outputs an attachment image, it can add a srcset that lists available files and their widths.
The browser looks at that list together with the sizes rule, the viewport width, and the screen density. It then chooses a file it thinks is large enough for the rendered image. WordPress has supported this responsive image system since version 4.4.
You usually do not need to hand-write srcset for normal Media Library images. If a page builder, custom template, or plugin bypasses WordPress image functions, however, you should inspect the final markup and make sure the responsive attributes are still present.
Why sizes matters so much
The srcset is only a menu of files. The sizes attribute tells the browser how much layout space the image is expected to use. If the browser is told that an image will be nearly as wide as the viewport, it may choose a much larger candidate than the design really needs.
Imagine a two-column desktop layout where the content image is about 600 pixels wide. On a phone it becomes almost full width. A good sizes rule can describe those two cases. A poor rule may tell every browser to plan for 100 percent of the viewport, even on a 1400-pixel monitor where the content column is far narrower.
This is one reason an image can look perfectly sized in CSS while the downloaded file is still too large. CSS controls display. Responsive image attributes help control the file choice.
How WordPress builds the markup
WordPress includes functions that calculate source sets and sizes values for attachment images. The default behavior works well for many normal content images. Themes can adjust it when their layout needs a more exact rule.
If you are building a custom theme, use WordPress image functions instead of printing the original upload URL by hand. The normal functions preserve useful attachment metadata and make responsive markup easier to generate. This also works better with WordPress loading logic for lazy loading and fetch priority.
Our guide to WordPress image optimization covers file formats and compression. Responsive markup is the next step: it helps send the right dimensions after you have created efficient files.
Find oversized image downloads
Open Chrome DevTools and load the page at the viewport size you want to study. In the Network panel, look at image requests and their transferred size. Inspect the image element and compare its displayed width with the intrinsic width of the file that was selected.
A 1600-pixel image displayed at 360 CSS pixels is not automatically wrong because high-density screens may need more physical pixels. But if a normal phone is downloading a 3000-pixel original for a small card thumbnail, something is wrong.
PageSpeed Insights can also flag image opportunities. Use those findings as clues, not as orders to install another plugin. First determine whether the problem is the source file, missing intermediate sizes, a wrong sizes rule, a CSS background image, or markup that bypasses WordPress.
Regenerate sizes after changing a theme
A new theme may register different image sizes from the old one. Existing uploads do not always have every new derivative because those files were created when the image was first uploaded. This can leave older posts without the best candidate for the current design.
If you change theme image sizes, regenerate the needed thumbnails carefully. Back up first on a large media library. Regeneration can use CPU, disk, and time, and it can create many files. Do not generate ten near-identical sizes just because a theme option allows it.
Too many registered sizes also increase storage use for every new image. Keep sizes that match real layout needs: cards, content widths, featured images, and other repeated patterns.
Watch custom image widgets and page builders
Some builders output an image as a CSS background instead of an HTML image. Background images do not use srcset and sizes in the same way. If a large hero is a background, the browser may receive one large file for every screen unless the builder creates its own responsive CSS.
Other widgets may request the WordPress “full” image even when the visual box is small. Check the generated HTML rather than trusting the label in the editor. A widget called “medium” may still end up with custom markup after optimization tools rewrite the page.
Responsive images and LCP
The largest visible image near the top of a page often becomes LCP. If the browser selects a file much larger than necessary, it spends extra time transferring and decoding it. If the selected file is too small, it can look soft on high-density screens.
The goal is not always the smallest possible file. The goal is a file large enough for the rendered slot at the current density without wasting far more bytes than needed. For a full LCP workflow, read how to improve LCP.
Do not lazy-load that important image just because it has responsive sources. WordPress lazy loading controls timing; responsive images control selection. Both need to be correct.
Use width and height attributes
WordPress attachment images normally include intrinsic width and height. Those attributes help the browser reserve the correct aspect-ratio space before the file arrives. This reduces layout movement.
If a custom template strips those dimensions, the page can shift when the image loads. That can hurt Cumulative Layout Shift even if the image file itself is small. Our WordPress CLS guide explains how reserved space protects the layout.
Do not solve responsive images with device detection
Server-side phone detection is usually not needed just to send a suitable content image. The browser already knows its viewport and pixel density. Responsive image markup lets it make the choice from a list of available candidates.
Device detection can also be brittle because user agents change and cache systems may serve the wrong variant if pages are split poorly. Keep one responsive page when you can, and let standards-based image selection do its job.
A practical audit
- Test a normal article, the home page, and one image-heavy page.
- Inspect the important
imgelements forsrcsetandsizes. - Compare the displayed width with the source file chosen by the browser.
- Check mobile and desktop widths, not just one device.
- Find widgets that use original files or CSS backgrounds.
- Regenerate only the image sizes your current design really needs.
- Retest transfer size, LCP, and visual quality.
If total page weight is still high after image selection is fixed, review third-party scripts and other large resources rather than squeezing images until they look bad.
Check content width, not only viewport width
A common responsive-image mistake is to treat the viewport as the image width. Many WordPress layouts have a content column that stops growing long before the browser window does. A 1440-pixel desktop viewport may hold a 760-pixel article column, while the sidebar and page margins use the rest of the space.
If the sizes rule says the image will use 100vw at that width, the browser can choose a much larger source than needed. Measure the real content slot in the layout. Cards, sidebars, full-width heroes, and article images may each need a different rule.
Also check breakpoints where the layout changes. A card that is one third of a desktop row may become one half of a tablet row and nearly full width on a phone. The browser can make a better choice when the sizes rule describes those changes instead of using one rough value for every screen.
After the audit, save one mobile and one desktop example with the chosen source width. Those examples become a simple regression check after theme, builder, or image-plugin updates.
Sources and further reading
- WordPress responsive images API
- WordPress srcset function
- WordPress sizes function
- MDN responsive images guide
- Web.dev responsive images
- Web.dev LCP optimization