cyrilwanner / next-optimized-images

🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v3: Defining an array densities does not generate images

filipjakov opened this issue · comments

Great job on the new version, really like the dx.

Version:

  • "next-optimized-images": "^3.0.0-canary.10"

Setup:

  • everything per recommended in the docs
  • next.config.js:
javascript
    [
      optimizedImages,
      {
        images: {
          handleImages: ['jpeg', 'png', 'webp'],
          webp: {
            quality: 100,
            nearLossless: true,
          },
        },
      },
    ],
  • images.config.js:
module.exports = {
	default: {
		webp: true,
		densities: [1, 2]
	},
};

Usage:

...
<Img src={Hero} />
...

The problem

  • original image is png; the only thing generated is an optimized png and webp image, but no images with defined densities

  • various densities reference the "same" image element

  • also does not work when defining densities inline, on the Img elements themselves

  • HTML looks like the following

<picture>
  <source type="image/webp" srcset="/_next/static/chunks/images/landing-hero-d7a2b56784e764765f7be1e94ebcc13a.webp, /_next/static/chunks/images/landing-hero-d7a2b56784e764765f7be1e94ebcc13a.webp 2x, /_next/static/chunks/images/landing-hero-d7a2b56784e764765f7be1e94ebcc13a.webp 3x">
  <source type="image/png" srcset="/_next/static/chunks/images/landing-hero-0de1f1910a9d4f45cf113b0277fe4f8a.png, /_next/static/chunks/images/landing-hero-0de1f1910a9d4f45cf113b0277fe4f8a.png 2x, /_next/static/chunks/images/landing-hero-0de1f1910a9d4f45cf113b0277fe4f8a.png 3x">
  <img src="/_next/static/chunks/images/landing-hero-0de1f1910a9d4f45cf113b0277fe4f8a.png">
</picture>

Expected behavior

  • images with defined densities get generated and referenced in the HTML as expected

Any news on this?