Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

unoptimized images are not following basepath #68498

Closed
chandrahaas02 opened this issue Aug 4, 2024 · 5 comments
Closed

unoptimized images are not following basepath #68498

chandrahaas02 opened this issue Aug 4, 2024 · 5 comments
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.

Comments

@chandrahaas02
Copy link

chandrahaas02 commented Aug 4, 2024

Link to the code that reproduces this issue

https://github.com/chandrahaas02/portfolio

To Reproduce

by adding unoptimized : true we are also skipping basepath formatting to image src's srcs

Current vs. Expected behavior

If images are unoptimized the src= "basepath/image.png" but they are still "/image.png"

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jul 25 18:17:34 UTC 2024
  Available memory (MB): 15690
  Available CPU cores: 12
Binaries:
  Node: 18.20.2
  npm: 10.5.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: 14.2.5
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: export

Which area(s) are affected? (Select all that apply)

Image (next/image)

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

@chandrahaas02 chandrahaas02 added the bug Issue was opened via the bug report template. label Aug 4, 2024
@github-actions github-actions bot added the Image (next/image) Related to Next.js Image Optimization. label Aug 4, 2024
@ugursepetci
Copy link

doesn't it work that way?

Screenshot 2024-08-04 at 22 08 13

@chandrahaas02
Copy link
Author

hey @ugursepetci yeah I tried that also but it is not adding basePath so github actions for some reason want images unoptimized because this github pages build is not requesting the correct image

exported index.html

@samcx
Copy link
Member

samcx commented Aug 8, 2024

@chandrahaas02 You're referring to basePath in your next.config.mjs, correct (your :repro: is missing this)?

@chandrahaas02
Copy link
Author

@chandrahaas02 You're referring to basePath in your next.config.mjs, correct

yeah I just avoided it there since github automatically adds that but yeah I just removed that and added it back here so that it is better visible

you can also find an open github issue actions/configure-pages#67 which is very similar

@samcx
Copy link
Member

samcx commented Aug 15, 2024

@chandrahaas02 You have to statically import it and move the image out of /public.

import haas from "./haas.png"

<Image src={haas} width={500} height={500} alt="me" />

@vercel vercel locked and limited conversation to collaborators Aug 15, 2024
@samcx samcx converted this issue into discussion #68960 Aug 15, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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