Next image not working?
Answered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
import ErrorImage from "./img/404.png";
....
<Image src={ErrorImage} alt="" placeholder="empty" />Answered by Orinoco Crocodile
okay I found the issue - for some reason it didnt like next being in a subdirectory
25 Replies
Hi, you must provide wither :
- a width and height for the image
- or a fill attribute
https://nextjs.org/docs/app/building-your-application/optimizing/images#fill
- a width and height for the image
- or a fill attribute
https://nextjs.org/docs/app/building-your-application/optimizing/images#fill
Orinoco CrocodileOP
Still errors with fill
If you use fill, you might wanna set a sizes for the media queries (refer to documentation in Image optimisation) I have a video on this, i'll look for it
Try logging you image path.
I had issue when pushing into Vercel.
So the best option is to put your image in the public directory and call it from the src attribute
Try logging you image path.
I had issue when pushing into Vercel.
So the best option is to put your image in the public directory and call it from the src attribute
as so that
// your image is in puclic/img/image.png
<Image src={"/img/image.png"} alt="" placeholder="empty" />Actually, You do not need these attributes for static imported images, it's likely an internal problem.
Try delete
Try delete
.next folder and restart again?using URLs instead might solve this error though, but the error shouldn't be occurring at first
@fuma Actually, You do not need these attributes for static imported images, it's likely an internal problem.
Try delete `.next` folder and restart again?
Okay, that;s how i personaly solved the issues I had.
Orinoco CrocodileOP
will try delete .next thanks
Same error
logging the image shows it exists and the path works
@Max as so that
js
// your image is in puclic/img/image.png
<Image src={"/img/image.png"} alt="" placeholder="empty" />
You may give this solution a try though
Otherwise I'll normally recommend re-installing
node_modules, the error is about missing a dependency base64-js (and next/image works for me)Orinoco CrocodileOP
will try reinstalling
i dont see base64-js as a dependency anywhere though
Yeah I had never experienced such an error, that's pretty strange
perhaps a peer dependency
Orinoco CrocodileOP
should i install it?
maybe?
Orinoco CrocodileOP
didnt seem to do anything
Alright, can you provide a minimal reproducible repo now?
Orinoco CrocodileOP
What site would you prefer I use to host it?
You don't have to host the app, just create a repo on github
so that I can debug it
Orinoco CrocodileOP
okay I found the issue - for some reason it didnt like next being in a subdirectory
Answer