next.js icon indicating copy to clipboard operation
next.js copied to clipboard

next.config is not work correct with images/unoptimized

Open Shramkoweb opened this issue 2 years ago • 1 comments

Verify canary release

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

Provide environment information

Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 Binaries: Node: 16.15.1 npm: 8.11.0 Yarn: N/A pnpm: N/A Relevant packages: next: 12.1.0 react: 17.0.2 react-dom: 17.0.2

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

next export

Describe the Bug

In our project we write custom loader without width/height and have console warn about it.

Image with src "/images/***.png" has a "loader" property that does not implement width. Please implement it or use the "unoptimized" property instead.
Read more: https://nextjs.org/docs/messages/next-image-missing-loader-width

In https://nextjs.org/docs/messages/next-image-missing-loader-width this link next recomended use

module.exports = {
  experimental: {
    images: {
      unoptimized: true,
    },
  },
}

But when i add this rule to config - a have the same warn in console.

CleanShot 2022-07-19 at 14 48 32@2x

Expected Behavior

No warn in console when use unoptimized: true

Link to reproduction

https://codesandbox.io/s/funny-breeze-iwt0yx?file=/next.config.js

To Reproduce

  1. Implement custom loader without width and height params
  2. See warn in console
  3. Go to https://nextjs.org/docs/messages/next-image-missing-loader-width
  4. Add the unoptimized prop.
  5. Warn is still in console

Shramkoweb avatar Jul 19 '22 13:07 Shramkoweb

It works with v12.3.2 of next.js and my configuration is the below

const nextConfig = {
  ...
  images: {
    unoptimized: true
  }
}

hiromaily avatar Nov 07 '22 13:11 hiromaily

@Shramkoweb This is not an bug. This functionality was introduced in version 12.2.0.

You, on the other hand, using version 12.1.0.

  • https://github.com/vercel/next.js/releases/tag/v12.2.0

I think it's worth closing this issue.

oritwoen avatar Jan 13 '23 14:01 oritwoen

@Shramkoweb This is not an bug. This functionality was introduced in version 12.2.0.

You, on the other hand, using version 12.1.0.

  • https://github.com/vercel/next.js/releases/tag/v12.2.0

I think it's worth closing this issue.

From PR So if next export is a hard requirement, the quickest path forward is to disable Image Optimization API. So this PR adds a new configuration option to next.config.js:

But if you read my issue, you can see that after adding this parameter unoptimized: true, which is described in the documentation and in PR, the error does not disappear.

Shramkoweb avatar Jan 13 '23 14:01 Shramkoweb

This doesn't seem to be the case when you move the property out of experimental!

samcx avatar Feb 28 '24 01:02 samcx

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

github-actions[bot] avatar Mar 13 '24 12:03 github-actions[bot]