next/image Intrinsic image sizes are the same in srcSet #38276
Replies: 11 comments 4 replies
-
Hi, You are correct to assume:
Yes. What's going on?The thing is that the src-set is used to download images as the screen width changes. You are starting from the largest viewport you've got, so the browser gets the image source for that one, and since it already has it, it'll use it for any, and all, narrower screens. Try to narrow your screen, and reload the site, now you'll see the image loaded by the browser is the one that's matches the src-set media queries, and for any smaller screen, this image is used. If you stretch the viewport, the browser starts to download the bigger size images. ExperimentTry with this demo, https://image-component.nextjs.gallery/layout-fill, start at narrow screen, and see the size of the first image, it should be about 7kB, all src-sets show the same data. As you stretch the viewport, the other src-sets, start to get their own size data. You can see these new request being made in the network tab as well! However, if you start from a very wide screen and narrow down the viewport... nothing happens, you still have the 35kB image loaded by the browser for the wide screen. |
Beta Was this translation helpful? Give feedback.
-
Maybe relevant: #37265 |
Beta Was this translation helpful? Give feedback.
-
Hi, I stumbled into the same problems with next 13.0.0 Simple image with height and width is not providing correct srcset for smaller screens. Google is complaining with "Properly size images". Do I overlook something ovious or is there any movement on this most basic use-case? |
Beta Was this translation helpful? Give feedback.
-
I'm so impressed that this just sits here unattended to / unaddressed |
Beta Was this translation helpful? Give feedback.
-
We're facing the same issue. I'm surprised that a framework vastly marketed because of its optimisation benefits fails in such a basic task. The subject deserves at least better documentation and possibly a working solution. |
Beta Was this translation helpful? Give feedback.
-
Still no update on this matter 1 year later ? |
Beta Was this translation helpful? Give feedback.
-
Hh |
Beta Was this translation helpful? Give feedback.
-
Not sure if it was an actual issue, since you‘re looking at the srcsets inside of the developer tools. You should check the network tab and look how much data is transferred. If everything works fine you can see the reduces file sizes inside of the network records. |
Beta Was this translation helpful? Give feedback.
-
I'm facing this, but only when using responsive mode in Chrome. I think the emulator starts with a large screen, then scales down to a smaller size to show the mobile version, and it causes larger images to load first (just like @icyJoseph mentioned above) |
Beta Was this translation helpful? Give feedback.
-
@hou-austin I am using next js 15 and I added Sharp package and now it works for me. |
Beta Was this translation helpful? Give feedback.
-
✅ Workaround to Customize
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using
next/image
, the "optimized image" all have the same sizes. Are the multitudes of generated URLs supposed to be of different sizes? I don't see the point of using this component otherwise. Here's the code:I've also tried out the other layout options, none of which seem to generate differently sized images.
and the generated outerHTML using layout
fill
:When I visit the links of the generated images, they are definitely the original size. Is there something I'm doing wrong? From what I see in the docs, it seems like the
sizes
attribute's default should work fine.Examples:



Beta Was this translation helpful? Give feedback.
All reactions