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 Optimization loads also original image #36034

Closed
1 task done
marco910 opened this issue Apr 9, 2022 · 3 comments
Closed
1 task done

Image Optimization loads also original image #36034

marco910 opened this issue Apr 9, 2022 · 3 comments
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.

Comments

@marco910
Copy link

marco910 commented Apr 9, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022
Binaries:
  Node: 14.15.3
  npm: 6.14.9
  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 100.0.4896.75

How are you deploying your application? (if relevant)

next start (PM2)

Describe the Bug

I'm using the built-in image optimization of Next.js to optimize the images from my headless CMS. When I have a look in the Network tab of the dev tools in Chrome I see that there is also the original image requested from the CMS. Is that the correct behavior? I don't think so because then I could also display the original image directly on the page without optimization.

The original images are more than 1 MB in some cases on my site, which influences the performance of the site negatively.

Expected Behavior

The expected behavior is that Next.js requests the original image from the CMS on the server-side, optimizes it, and responses to the client with only the optimized image.

To Reproduce

  1. Upload an image to a webserver or anywhere else, where you can request it from.
  2. Use this code to display it on your Next.js site:
<Image
 src={imageURL}
placeholder="blur"
blurDataURL={imageURL}
layout="fill"
objectFit="cover"
alt={altText}
title={titleText}
draggable="false"
/>
  1. Run the Next.js site with npm start in production and check your Network tab when reloading the page.
@marco910 marco910 added the bug Issue was opened via the bug report template. label Apr 9, 2022
@balazsorban44 balazsorban44 added the Image (next/image) Related to Next.js Image Optimization. label Apr 9, 2022
@noobyogi0010
Copy link

@balazsorban44 I would love to work on this issue if no one else has already taken it up.

@balazsorban44
Copy link
Member

balazsorban44 commented Apr 11, 2022

The issue here is that you set blurDataURL to the source image URL.

From the docs:

Must be a base64-encoded image. It will be enlarged and blurred, so a very small image (10px or less) is recommended. Including larger images as placeholders may harm your application performance.

https://nextjs.org/docs/api-reference/next/image#blurdataurl

@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 May 11, 2022
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.
Projects
None yet
Development

No branches or pull requests

3 participants