Unsplash Image not rendering on to the page
Answered
Sloth bear posted this in #help-forum
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
/ @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
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
and try again 😉
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 😉
11 Replies
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
and try again 😉
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
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?
rigth click on image > copy image url 😄
Sloth bearOP
oh! I see
or just download it in top-right corner and import from project (best approach)
Sloth bearOP
got it!!, Thanks for the help @Z4NR34L ✌ï¸
I'm glad to help. Happy Coding!
Pembroke Welsh Corgi
yeah better off putting in your project as URL's can change or get delted
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
Pembroke Welsh Corgi
also right click on Zanreals message click apps, mark solution.