Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image srcset size widths not generated at all #47613

Closed
1 task done
apfelbox opened this issue Mar 28, 2023 · 4 comments
Closed
1 task done

Image srcset size widths not generated at all #47613

apfelbox opened this issue Mar 28, 2023 · 4 comments
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization. locked

Comments

@apfelbox
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.12.1
      npm: 8.19.2
      Yarn: N/A
      pnpm: 8.0.0
    Relevant packages:
      next: 13.2.5-canary.20
      eslint-config-next: 13.2.4
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Image optimization (next/image, next/legacy/image)

Link to the code that reproduces this issue

To Reproduce

We are using the image component with a custom loader. However for regular images, there are no image sizes generated anymore.

Only the 1x and 2x sizes are generated, however no screen width based ones.

Describe the Bug

We use the image like this:

const image = {
    src: "...",
    width: ...,
    height: ...,
};

<Image src={image} alt={alt} />

But now it just generates an image with srcset 1x and 2x and doesn't use the image sizes at all. This way we use the image with 4000px width even on mobile devices.

Expected Behavior

It should always generate the different width-sizes as well, to avoid loading huge sizes on mobile.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@apfelbox apfelbox added the bug Issue was opened via the bug report template. label Mar 28, 2023
@github-actions github-actions bot added the Image (next/image) Related to Next.js Image Optimization. label Mar 28, 2023
@styfle
Copy link
Member

styfle commented Jun 22, 2023

The 1x/2x is the default behavior for fixed width images.

If you are using responsive images, you need to set the sizes prop.

@styfle
Copy link
Member

styfle commented Jun 22, 2023

Closing since responsive image usage was documented in PR #51457.

See the rendered documentation here: https://nextjs.org/docs/app/building-your-application/optimizing/images#responsive

@styfle styfle closed this as completed Jun 22, 2023
@apfelbox
Copy link
Author

Perfect, thank you (esp for the direct docs link) 👍

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization. locked
Projects
None yet
Development

No branches or pull requests

2 participants