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

Illustration for Where WordPress Images Lose Their Dimensions on the Add Image Dimensions WordPress page, showing a image diagram

Images inserted through the block editor or media library usually include width and height. Missing dimensions typically come from:

Common sources of images without dimensions
SourceWhy It Happens
Page buildersSome widgets output images without attributes
Theme templatesCustom code that prints image URLs directly
Sliders and galleriesImages inserted by JavaScript
Logos and iconsAdded through customizer settings or custom HTML
Third-party widgetsReview badges, social feeds, ads
SVG imagesUploaded SVGs may lack width and height
Images in custom HTML blocksPasted code without attributes

How to Find Images Without Dimensions

  1. Run PageSpeed Insights

    Look at the Layout shift culprits insight, which lists elements that shifted, including unsized images.

  2. Use Chrome DevTools

    Inspect images near shifting content and check for width and height attributes in the HTML.

  3. Check your logo and header

    These appear on every page, so one fix helps the whole site.

  4. 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

Illustration for Fix 2: Fix Them at the Source on the Add Image Dimensions WordPress page, showing a image diagram

For images the automatic fix can't reach, or if you prefer clean source code:

Fix 3: Reserve Space for Other Media

The same principle applies beyond images:

Reserving space for non-image elements
ElementHow to Reserve Space
Iframes and videosWidth and height attributes, or a fixed aspect-ratio container
YouTube embedsAspect-ratio container, or a preview image of the same size
AdsFixed-size containers for each slot
CSS background imagesSet height or aspect ratio on the container
SlidersFixed 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.

How the browser reserves space
Image AttributesDisplayed WidthSpace Reserved Before Loading
1200 × 800600 px400 px tall
1200 × 800360 px (phone)240 px tall
NoneAny0 px, then jumps when loaded

Checking Your Fix Worked

Illustration for Checking Your Fix Worked on the Add Image Dimensions WordPress page, showing a image diagram
  1. Clear all caches

    Plugin, host and CDN.

  2. Reload with a slow connection

    Use DevTools network throttling to slow image downloads.

  3. Watch the layout

    Text should stay put while images fill reserved boxes.

  4. Re-run PageSpeed Insights

    Layout shift culprits should no longer list unsized images.

  5. 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.