Skip to content

[Image] Loader config is ignored when using the unoptimized prop #50764

@zignis

Description

@zignis

Verify canary release

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

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Home Single Language
    Binaries:
      Node: 16.18.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.4
      eslint-config-next: 13.4.4
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.5

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 or a replay of the bug

https://codesandbox.io/p/sandbox/ecstatic-matan-zd6jjm?file=%2Fpages%2Findex.tsx%3A5%2C1

To Reproduce

Create an image (next/image) component with both the loader and unoptimized props.

Describe the Bug

From current docs:

When true, the source image will be served as-is instead of changing quality, size, or format. Defaults to false.

From my understanding, the unoptimized prop disables quality and size optimization, but it should still use the loader config. This is particularly useful when using an external CDN and requesting svg images, which does not require these optimizations. I know we can use the native img tag, but temporarily disabling optimization for an image with just a single props would be such a relief.

Expected Behavior

The loader configuration should be used when the unoptimized prop is set to true.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1493

Metadata

Metadata

Assignees

No one assigned

    Labels

    Image (next/image)Related to Next.js Image Optimization.linear: nextConfirmed issue that is tracked by the Next.js team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions