Next.js Discord

Discord Forum

Unsplash Image not rendering on to the page

Answered
Sloth bear posted this in #help-forum
Open in Discord
Avatar
Sloth bearOP
next.config.js file -
/ @type {import('next').NextConfig} */
const nextConfig = {
images: {
domains: ['tailwindui.com'],
remotePatterns: [
{
protocol: 'https',
hostname: 'unsplash.com',
// port: '',
// pathname: '/
',
},
],
},
};

module.exports = nextConfig;


page.tsx file -
import Image from 'next/image'
import React from 'react'

function page() {
return (
<div className="container">
<div className="menu">
<div className="menu_item">
<div className="menu_item-image_wrapper">
<div className="menu_item-image_inner">
<Image
src="https://unsplash.com/photos/a-woman-sitting-on-the-floor-with-her-legs-crossed-EzaNI5SrUj4?utm_content=creditShareLink&utm_medium=referral&utm_source=unsplash"
width={100}
height={100}
alt="model"
/>
Page
</div>
</div>
</div>
</div>
</div>
);
}

export default page
Image
Image
Answered by Z4NR34L
You provided link to image SITE in src, nor an atualy image address, as you can see in error message - it's not a valid image. Change it to
https://images.unsplash.com/photo-1688309793858-2da85476bf4c?q=80&w=2776&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D

and try again 😉
View full answer

11 Replies

Avatar
You provided link to image SITE in src, nor an atualy image address, as you can see in error message - it's not a valid image. Change it to
https://images.unsplash.com/photo-1688309793858-2da85476bf4c?q=80&w=2776&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D

and try again 😉
Answer
Avatar
Sloth bearOP
it worked with little changes, but from where did you get this link
in future If I want to use another image what should be my approach?
Avatar
rigth click on image > copy image url 😄
Avatar
Sloth bearOP
oh! I see
Avatar
or just download it in top-right corner and import from project (best approach)
Avatar
Sloth bearOP
got it!!, Thanks for the help @Z4NR34L ✌️
Avatar
I'm glad to help. Happy Coding!
Avatar
Pembroke Welsh Corgi
yeah better off putting in your project as URL's can change or get delted
Avatar
But one thing is important in that case, don't use full-res images as it can easly drain your hobby plan bandwidth usage xD
Avatar
Pembroke Welsh Corgi
also right click on Zanreals message click apps, mark solution.