Next.js Discord

Discord Forum

Question about Image src (NEXT 14)

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
I passed the src into Next image like this below. When I inspected the code, it showed http://localhost:3000/_next/image?url=%2Fassets%2FservicesPage%2Fservices%2Fsecurity-system.png&w=1080&q=75. I would like to show the path like this http://localhost:3000/assets/servicesPage/services-banner-1.png. How can I achieve this? It's fine when I used .svg. Thank you.
 <Image
    fill
    src="/assets/servicesPage/services/security-system.png"
    alt="security system"
    style={{ objectFit: 'cover' }}
    sizes="(max-width: 900px) 0vw, (max-width: 1200px) 50vw, 33vw"
  />

53 Replies

@Ray btw why would you want to keep the url?
Transvaal lionOP
because the image is not found on production if using _next/image?url=%2Fassets%2FservicesPage%2Fservices%2Fsecurity-system.png&w=1080&q=75
ok i see the problem
you should import the image
import securitySystemImage from "/assets/servicesPage/services/security-system.png"

 <Image
  fill
  src={securitySystemImage}
  alt="security system"
  style={{ objectFit: 'cover' }}
  sizes="(max-width: 900px) 0vw, (max-width: 1200px) 50vw, 33vw"
/>
@Transvaal lion Yes, the image is put under `public` folder
how do you deploy your site?
@Ray how do you deploy your site?
Transvaal lionOP
build a docker image and upload it to EC2
look like something wrong with image optimisation on your setup
Transvaal lionOP
it is saying "url" parameter is required
have you used the wrong url?
oh there is a space
Transvaal lionOP
then the url should be provided
oh wait
it said w is required right?
Transvaal lionOP
tried before as well. same message "url" parameter is required
Transvaal lionOP
I can't. because it's a test site for a company.
any guide to set up image optimization on our own?
well, I would suggest try importing the image instead and try if it work with passing unoptimized props to <Image />
it should be working out of the box
@Transvaal lion Yes, I can open it.
nm, if you can open with this url
@Ray it is how it look like when image optimization enabled
Transvaal lionOP
No, I didn 't use standalone output
the url should look the same in dev
Transvaal lionOP
dev mode is working fine with optimized
how do you start the production build?
or how do you deploy it to production?
Transvaal lionOP
so maybe the docker image is not setup properly
yes sound like that
Transvaal lionOP
ok thank you for your help.
@Transvaal lion ok thank you for your help.
np, let me know when it works
Transvaal lionOP
Sure.