Add Image Dimensions WordPress - Stop Images From Shifting Your Layout (2026)
When an image has no width and height, the browser doesn't know how much space to save for it. The text loads, the image arrives, and everything below jumps down. Adding dimensions is one of the easiest Core Web Vitals fixes.
Why Dimensions Matter
Browsers lay out a page before every image has downloaded. If an image tag includes width and height attributes, the browser calculates the aspect ratio and reserves the right amount of space. When the image arrives, it fills that space and nothing moves.
Without dimensions, the browser reserves no space. The image pushes content down when it loads, causing a layout shift that counts toward Cumulative Layout Shift.
Modern CSS keeps images responsive even with width and height set: the browser uses the attributes for the aspect ratio while the image scales to fit its container.
Where WordPress Images Lose Their Dimensions
Images inserted through the block editor or media library usually include width and height. Missing dimensions typically come from:
| Source | Why It Happens |
|---|---|
| Page builders | Some widgets output images without attributes |
| Theme templates | Custom code that prints image URLs directly |
| Sliders and galleries | Images inserted by JavaScript |
| Logos and icons | Added through customizer settings or custom HTML |
| Third-party widgets | Review badges, social feeds, ads |
| SVG images | Uploaded SVGs may lack width and height |
| Images in custom HTML blocks | Pasted code without attributes |
How to Find Images Without Dimensions
Run PageSpeed Insights
Look at the Layout shift culprits insight, which lists elements that shifted, including unsized images.
Use Chrome DevTools
Inspect images near shifting content and check for width and height attributes in the HTML.
Check your logo and header
These appear on every page, so one fix helps the whole site.
Check templates, not just pages
Fixing a template fixes every page using it.
Fix 1: Add Dimensions Automatically
WP Rocket's Add missing image dimensions option, in its Image & Media settings, scans images in your page HTML and adds width and height where they're missing. It works for images in the HTML; images inserted later by JavaScript need fixing at the source.
After enabling it, clear the cache and re-test the pages that showed layout shifts.
Fix 2: Fix Them at the Source
For images the automatic fix can't reach, or if you prefer clean source code:
- Page builders: check image widget settings for size options, and update the builder, since many have improved this.
- Theme code: use WordPress functions that output complete image tags with dimensions, rather than printing a bare URL.
- Custom HTML: add width and height attributes matching the image's natural size or aspect ratio.
- Logos: set dimensions in your theme's logo settings or the header template.
Fix 3: Reserve Space for Other Media
The same principle applies beyond images:
| Element | How to Reserve Space |
|---|---|
| Iframes and videos | Width and height attributes, or a fixed aspect-ratio container |
| YouTube embeds | Aspect-ratio container, or a preview image of the same size |
| Ads | Fixed-size containers for each slot |
| CSS background images | Set height or aspect ratio on the container |
| Sliders | Fixed height for the slider area |
See reducing CLS for the full picture.
Width and Height With Responsive Images
A common worry is that fixed width and height attributes will make images stretch or overflow on mobile. They don't, as long as your theme uses standard responsive CSS that sets images to a maximum width of 100% with automatic height. Most modern WordPress themes already do this.
What the attributes provide is the aspect ratio. Browsers use it to calculate the correct height for whatever width the image ends up displaying at, before the file arrives.
| Image Attributes | Displayed Width | Space Reserved Before Loading |
|---|---|---|
| 1200 × 800 | 600 px | 400 px tall |
| 1200 × 800 | 360 px (phone) | 240 px tall |
| None | Any | 0 px, then jumps when loaded |
Checking Your Fix Worked
Clear all caches
Plugin, host and CDN.
Reload with a slow connection
Use DevTools network throttling to slow image downloads.
Watch the layout
Text should stay put while images fill reserved boxes.
Re-run PageSpeed Insights
Layout shift culprits should no longer list unsized images.
Check field CLS later
Search Console and PageSpeed Insights field data update over about four weeks.
Dimensions and Lazy Loading
Lazy-loaded images without dimensions are a common source of shifts: as visitors scroll, images appear and push content around. With dimensions in place, lazy loading doesn't cause layout shifts, because the space is already reserved. See lazy loading images.
Do Dimensions Affect Image Quality or Size?
No. Width and height attributes describe the image's shape; they don't resize or compress it. To make images smaller, resize and compress them separately. See optimizing images.
A Worked Example
A small shop's product pages fail CLS in field data. PageSpeed Insights shows the logo and a "trusted by" badge strip shifting content. The logo is set in the customizer, and the badges come from a third-party widget.
Enabling Add missing image dimensions fixes the logo, which is in the HTML. The badge widget inserts images with JavaScript, so the owner wraps it in a container with a fixed height. CLS moves into the good range in the following weeks.
Add Image Dimensions WordPress FAQ
Why does PageSpeed Insights flag images without dimensions?
Without width and height, the browser can't reserve space, so content shifts when the image loads, which hurts CLS.
Does WordPress add image dimensions automatically?
For images inserted through the editor, usually yes. Themes, page builders and plugins sometimes output images without them.
Will adding width and height break my responsive design?
No. With standard responsive CSS, images still scale; the browser just uses the attributes for the aspect ratio.
Can WP Rocket add missing image dimensions?
Yes. Its Add missing image dimensions option adds them to images in your page HTML.