Shopify / hydrogen

Hydrogen lets you build faster headless storefronts in less time, on Shopify.
https://hydrogen.shop
MIT License
1.34k stars 261 forks source link

Prevent <Image> from generating srcset which doesn't support image size #2456

Closed andershagbard closed 1 week ago

andershagbard commented 3 weeks ago

Which package or tool is having this issue?

hydrogen-react

What version of that package or tool are you using?

2024.7.1

Steps to Reproduce

  1. Upload a image to Shopify. E.g. 1500x1000
  2. Use <Image /> component, and set aspectRatio to 1/2
  3. Large srcset values will now load "correctly" with width and height attributes in correct aspect, but Shopify server can't transform images with width or height higher than original image size, and then return original image.

Expected Behavior

I would expect the <Image /> image component to omit any srcset value when it knows that it wont be generated for the specific aspect ratio

andershagbard commented 2 weeks ago

@wizardlyhel I am willing to work on this, if the issue should be resolved?

wizardlyhel commented 2 weeks ago

@andershagbard We happy if you can submit a PR for it.