Next.js Discord

Discord Forum

Images are downloaded instead of opened in a new tab

Unanswered
American Coot posted this in #help-forum
Open in Discord
American CootOP
Hi, when I right-click on any image served by next/image and select "Open image in a new tab", on both Chrome and Firefox, the image is downloaded and not opened in a new tab as expected.

When I replace <Image> by <img> the image is correctly opened in a new tab.

I can observe this behavior in various 15.1 and 15.2 projects, without exception. In 14.x it was definitely not like this and images were opened in new tabs, as I expect them to do.

I cannot find anything about that behavior in the documentation, nor can I find something anywhere on the web. Is this by purpose or a bug? Any solutions, workarounds??

Thanks...

7 Replies

Hey @American Coot , as far as I know, this behavior in Next.js 15.x is intentional due to how next/image optimizes and serves images through an internal API route, which causes them to download instead of opening in a new tab. To restore the expected behavior, you can use the unoptimized prop (<Image src="/your-image.jpg" unoptimized />), though this disables Next.js' default image optimization and serves the image as a standard file. Alternatively, as you mentioned, using a regular <img> tag instead of <Image> ensures direct access. Hosting images externally (e.g., on a CDN) is another solution. If image optimization isn’t crucial, unoptimized is the simplest fix. Let me know if you need more details!
American CootOP
Thank you @Bertholdt Hoover for your reply. Serving unoptimized images is definitely not a solution for me.

To make the issue a little bit more precise: It is not my goal, that users should be able to view unoptimized/original images in a new tab. I want to prevent, that when a user (for whatever reason) clicks on "Open image in a new Tab" gets his download folder spammed, without seeing a picture.

The images, that are downloaded, are actually optimized ones, matching the size and quality specified in <Image>. Back in NextJS 14 it were also optimized images, that were viewed in the new tab. So it is actually this change in the component's behavior (download optimized instead of viewing optimized), I am wondering about.
@American Coot Appreciate you posting your concern. There may be potentially some workarounds to fixing this problem. Can you also tell me how you're loading your images, are they being retrieved from a public folder, CDN, or some external API? This will let me better support you.
American CootOP
@Bertholdt Hoover Thank you very much. I appreciate your helpfulness.

For websites, I use Strapi as CMS. But this issue does not seem to depend on the image source. It appears already when I set up a clean Next installation via 'npx create-next-app@latest', copy a random JPG into the public folder, display it on default page, and run it in development mode on my local machine.

I can reproduce the error on all my devices, including android phone (with firefox mobile, chrome and duckduck.go browser)
Hey @American Coot, I looked into what you mentioned and found that Next.js provides an official way to disable image downloads by default. According to their documentation, you can achieve this by updating your next.config.js as follows:
module.exports = {
  images: {
    contentDispositionType: 'inline',
  },
}

You can find more details in the official guide here: [Next.js Docs](https://nextjs.org/docs/app/api-reference/components/image#contentdispositiontype)
Hope this helps! Let me know if you have any questions.
American CootOP
@Bertholdt Hoover Thank you so much! This is the solution!

I was searching the documentation for hours to find this, but did not see it myself.

I really appreciate your efforts!!! Thank you!
@American Coot You're very welcome! I'm so glad I could help you find the solution. I know how frustrating it can be when you're searching for something on the documentation for hours and can’t seem to find it, so I'm happy I could help. If you have any more questions, feel free to reach out! 🙌🏼