Lighthouse audit image-aspect-ratio · Best Practices

"Displays images with incorrect aspect ratio": how to fix it

Quick answer: Lighthouse flags "Displays images with incorrect aspect ratio" when an img is drawn in a box whose width-to-height ratio differs from the image file, so it looks stretched. Fix it by letting one dimension follow the other with height: auto, or keep the fixed box and add object-fit: cover so the image is cropped, not distorted.
View raw .md for LLMs / your notes

Lighthouse prints Displays images with incorrect aspect ratio when an <img> is drawn in a box whose shape does not match the shape of the image file, so the picture looks stretched or squashed. A square 800 x 800 product photo shown at 300 x 200 is the typical case. In our study of 269 Shopify storefronts, 52 of them (19.3%) failed this audit. It is a pass or fail check in the Best Practices category with a weight of 1. This page covers what Lighthouse compares, the CSS that causes the distortion, and the fix for each cause.

TL;DR

What does "Displays images with incorrect aspect ratio" mean?

Every image file has a natural size, for example 1200 x 800 pixels, and so a natural aspect ratio, here 1.50. The page then displays it at some size in CSS pixels. If the displayed ratio is different, the browser has stretched the image in one direction to fill the box.

Lighthouse lists each such image with two columns:

ColumnExampleMeaning
Aspect Ratio (Displayed)300 x 200 (1.50)The size of the box on the page and its ratio
Aspect Ratio (Actual)800 x 800 (1.00)The natural size of the file and its ratio

Per the audit source, a difference of less than 2 pixels in the displayed size is ignored, so sub-pixel rounding does not fail it. One listed image fails the audit.

Which images does Lighthouse check?

Only images that the browser is actually stretching. The audit skips:

So the list is short and specific: real <img> elements, with the default object-fit: fill, drawn in a box of the wrong shape.

Why are my images displayed with the wrong aspect ratio?

  1. CSS sets both width and height. A thumbnail grid or avatar rule such as img { width: 300px; height: 200px; } forces every image into one shape, whatever was uploaded.
  2. height: 100% or a fixed height with a fluid width. The width follows the column and the height follows something else, so the ratio changes at every screen size.
  3. Flexbox stretching. An <img> that is a direct child of a flex row gets the default align-items: stretch and grows to the height of the tallest sibling while its width stays put.
  4. Wrong width and height attributes. Someone fixed unsized images by typing numbers that do not match the file, or the image was replaced and the old numbers stayed, and CSS without height: auto honors both.
  5. srcset candidates with different shapes. A wide crop for desktop and a tall crop for mobile in one srcset, displayed in a box sized for only one of them.
  6. A CMS or app that outputs fixed dimensions. Sliders, review widgets and logo strips often hard-code a box.

How do I fix "Displays images with incorrect aspect ratio"?

1. Let the height follow the width

For images that should show whole, remove the fixed height:

img {
  max-width: 100%;
  height: auto;
}

Keep the width and height attributes in the HTML, set to the real pixel size of the file. With height: auto the browser uses them only as a ratio, which reserves the right space and prevents layout shift.

2. Keep the box and crop with object-fit

For grids, cards and avatars where every image has to fill the same shape:

.card img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

object-fit: cover fills the box and crops the overflow. object-fit: contain shows the whole image with empty space around it, which suits logos. Use object-position to choose which part survives the crop.

3. Stop flexbox from stretching the image

.row { display: flex; align-items: flex-start; }
/* or, on the image only */
.row > img { align-self: flex-start; }

Wrapping the image in a <div> and making the wrapper the flex item also works.

4. Correct the width and height attributes

Read the natural size in DevTools: hover the <img> in the Elements panel and the tooltip shows the rendered size and the intrinsic size. Set the attributes to the intrinsic numbers. If the image was replaced, update them.

5. Use <picture> for different crops

When mobile and desktop need different shapes, that is art direction, and srcset alone cannot describe it. Give each crop its own <source> with its own width and height:

<picture>
  <source media="(max-width: 600px)" srcset="hero-tall.jpg" width="600" height="800">
  <img src="hero-wide.jpg" width="1600" height="900" alt="...">
</picture>

6. Crop the file itself

If a slot is always 3:2, serve a 3:2 file. The browser then has nothing to stretch or crop, and you ship fewer bytes than with a larger image cropped in CSS.

How do I fix it in WordPress, Shopify, or Next.js?

How do I verify the fix?

  1. Re-run Lighthouse. "Displays images with incorrect aspect ratio" should move to the passed audits.
  2. Resize the window from phone width to desktop width and watch the images that were listed. A ratio that is right at one width can be wrong at another.
  3. In DevTools, hover a fixed image in the Elements panel and compare the rendered size with the intrinsic size. The two ratios should match, or object-fit should be set.
  4. Run Lighthouse in both mobile and desktop modes. The mobile run only sees the mobile layout.

What mistakes should I avoid?


Audit your URL at https://lighthouse-md.com.

Audit your page now

Paste your URL, get scores plus a CLAUDE.md plan for Claude Code.

Run audit →
Add us as a preferred source on Google

One click, and Google shows more of lighthouse-md.com in your search results.