You have some of the most unique thumbnails I've every seen.
@leighhalliday4 жыл бұрын
Haha, thank you :) Those are very kind words!
@systemmanager1863 жыл бұрын
You can control bit more with adding object fit properties to the IMAGE. It's like working with background image in Vanilla CSS
@silenux74194 жыл бұрын
Great video Leigh. Thanks. Only thing missing is the blur image effect from Gatsby.
@leighhalliday4 жыл бұрын
True! I personally think it is missing cropping as well!
@aminedaimallah3104 жыл бұрын
nice video, i can't wait to start learning nextjs
@leighhalliday4 жыл бұрын
Thanks Amine! I have a fullstack react/nextjs course launching in the next 2 months, hopefully it will be able to help you!
@aminedaimallah3104 жыл бұрын
@@leighhalliday oh really, i will definitely check it, i hope it won't be too long haha
@sanctipaprichio3 жыл бұрын
thank you for clear explanation
@leighhalliday3 жыл бұрын
Glad it helped!
@bryan3333333333333334 жыл бұрын
You can do this: img { object-fit: cover } and it won't squish your image
@leighhalliday4 жыл бұрын
Excellent! Thanks Bryan.
@styfle1234 жыл бұрын
Next.js 10.0.2 will have `objectFit="cover"` as a property. You can try it on canary today. github.com/vercel/next.js/blob/canary/examples/image-component/pages/layout-fill.js
@paulsimonongpin66894 жыл бұрын
this is a problem that a lot of developers are experiencing using layout="fill". glad they added objectFit props to image component. but since I'm doing tailwind className="object-cover" works as well
@susbedoo4 жыл бұрын
That thumbnail is a GOD level threat😅
@leighhalliday4 жыл бұрын
Haha... basically I just find old/funny pics and put text next to them :D
@rajashekhar4334 жыл бұрын
Thanks for the video and I'm facing one issue in a personal project that component level scss and adding images from css
@leighhalliday4 жыл бұрын
Hey Raj! Sorry, not quite sure how to help you with that issue specifically.
@polyander4 жыл бұрын
Thanks a lot for this, as always very useful. You say that cloudinary and imgix have their own Image components, which ones are you referring to exactly?
@leighhalliday4 жыл бұрын
These ones: Cloudinary - www.npmjs.com/package/cloudinary-react Imgix - www.npmjs.com/package/react-imgix
@polyander4 жыл бұрын
@@leighhalliday amazing, thank you! 🙂
@rajashekhar4334 жыл бұрын
Thanks for the video Facing one issue that component level scss file. Onload scss page loaded but navigate to other page in this respective scss not loading
@leighhalliday4 жыл бұрын
Hey Raj! I don't think this has anything to do with this video?
@rajashekhar4334 жыл бұрын
@@leighhalliday yeah just asking for help🙁 🙂
@ElmachitoSilbateador3 жыл бұрын
It's weird because in production, the image component doesn't work with a static image saved in public folder. But using a regular img tag, it worked for the same image
@leighhalliday3 жыл бұрын
Hmmm... weird! I honestly don't know off the top of my head what the issue is.
@roid15102 жыл бұрын
Is it possible to use the image component on the background css variable?
@monkeystylle3 жыл бұрын
can you set the props width and height in % like width={200%} instead of pixels? just like in css
@soris_bergeevich_shoyarbinov4 жыл бұрын
oh btw nice periwig on the preview
@leighhalliday4 жыл бұрын
Thank you! What's a periwig?
@phillipgimmi18502 жыл бұрын
thanks bud
@sabirahmed61914 жыл бұрын
Biggest drawback of using this I found was that the browser does not cache the images and request them all the time.
@leighhalliday4 жыл бұрын
Hmm really? That's too bad!
@sabirahmed61914 жыл бұрын
@@leighhalliday yup found it weird considering we want to optimize the network requests. Wish the cache headers were forwarded from the source file.
@poojagholap42214 жыл бұрын
how can we put css classname inside Image tag ?
@leighhalliday4 жыл бұрын
Not sure actually, does it work just with className prop?
@poojagholap42214 жыл бұрын
@@leighhalliday yeah it works
@iamdeveloper25804 жыл бұрын
Hi Leigh, Image shows incorrect images with correct URL, any idea about that?
@leighhalliday4 жыл бұрын
Hey Developer! Sorry... not sure why :(
@alfieqashwa4 жыл бұрын
So, if I configure cloudinary url in the next.config.js, and I persistence the public_id on prisma database, that's mean I can use Image from next/image instead of Image from react-cloudinary? and the code would be something like this: is that right? I'm just guessing and haven't try it yet. #cmiiw I already read the doc but still missed about this. Anyway, this is great tutorial as usual. Thank you.
@leighhalliday4 жыл бұрын
That's correct, Alfie. That said, you lose the ability to use all of the Cloudinary goodness that "react-cloudinary" gives you... cropping, transformations, etc... so for the course I'm building, I actually stuck with Image from "react-cloudinary" because I wanted to be able to crop.
@alfieqashwa4 жыл бұрын
@@leighhalliday me either. LoL...!! Oh my God, honestly I'm still feeling amaze about interaction on internet. What if there's no internet, a guy like me from Indonesia would never learn anything from you who live in Canada. Maybe it's because I can't talk about nextjs and prisma2 with my wife, or neighbours, and anyone in here. HAha :D
@PB72UK3 жыл бұрын
What happens if the image is coming from an image server? Rather than public folder?
@leighhalliday3 жыл бұрын
Hmm, I am not sure! You'll have to dive into the docs a bit to see how that works.
@nikitarudenko24654 жыл бұрын
At this point, next/image lacks two features IMO: 1. You can't use it for images that come from CMS because you need to know width and height somehow. You can't just drop in any image and it preserves the aspect ratio. Layout="fill" is weird and doesn't work as I expected. 2. I would like to see an option for the blurred image before it gets fully loaded like on Medium. I hope these will be added soon
@leighhalliday4 жыл бұрын
I agree! I think cropping is missing as well.
@wsymbiosis4 жыл бұрын
1. Good CMS output image properties like width, height, and alt so that should not be a problem. 2. Yes, layout="fill" is quite bad design-wise and should be rethought by the nextjs team. 3. I believe they are planning to release a medium-like initial blurred image
@TheShapingSickness3 жыл бұрын
For some reason when I use this component the images are brought to the forefront as if they had z-index: 9999, elements are hidden behind the images, I can't fix this.
@leighhalliday3 жыл бұрын
Hmm, I'm not sure off the top of my head. Does it say anything about this in their docs?
@xthebumpx4 жыл бұрын
One thing I'm not clear on -- does the component work for both SSG and SSR?
@leighhalliday4 жыл бұрын
Hey xdmx! I would imagine it's fine... that it just would render an `img` tag, but I haven't tried it :D
@xthebumpx4 жыл бұрын
How do you use the Image component in a markdown file? can it only be done in mdx/js/ts file?
@styfle1234 жыл бұрын
The Image component works everywhere React components do: mdx/jsx/tsx/etc. For plain md sources, you can use MDXProvider to map to like this blog post demonstrates nextjs.org/blog/markdown
@leighhalliday4 жыл бұрын
Looks like styfle123 has you covered!
@MobiusCoin3 жыл бұрын
This component isn't supported with SSG 😕
@arcadan3 жыл бұрын
Seems its different when you work with img from getStaticProps, I tried to use Cloudinary to be the loader, but it doesn't work. The property of the images from getStaticProps is "HTTP://..." i wonder how I can use it to load these images properly.
@leighhalliday3 жыл бұрын
Hmmm... I'm not sure what the issue is Daniel... sorry :(
@programmer40474 жыл бұрын
how can we do things like - background-size: cover;
@leighhalliday4 жыл бұрын
Hey Programmer! I think you'd just link to an image like normal, you wouldn't use the new Image component.
@rram68754 жыл бұрын
Little by little Next is making Gatsby redundant. Now all it needs is a kickass plugin ecosystem.
@leighhalliday4 жыл бұрын
I agree!! Next.js is my go-to React framework... I honestly think there are fewer and fewer use-cases where Gatsby makes sense. That said, I haven't converted www.leighhalliday.com from Gatsby to Next.js because there's some things I do there treating the MDX files as data that would be difficult to do in Next.js :D
@andyslezak36064 жыл бұрын
It’s like you’re a mind reader
@leighhalliday4 жыл бұрын
Muahahah :D
@ivanrg64063 жыл бұрын
Be aware: Image Optimization does NOT work on layout fill. So this component is pretty useless.
@leighhalliday3 жыл бұрын
Hey Ivan! What would you recommend as an alternative?
@indycinema4 жыл бұрын
Dudes. This just makes the build/compile time grow as everything is converted into 5 different resolutions for every image in the blog/site. It is a massive catastrophe in Gatsby, for what a more cumbersome srcset? Bottom line. Images are not the same as code. Images need to be exported by a human who cares once, not every compile. Notice no one would do this for video files, because compilation time would be years. Chasing Gatsby is insane. You run the nytimes!
@leighhalliday4 жыл бұрын
Hey Lawrence. This is all at run time, not build time... it generates them dynamically on the fly as they are requested. It won't add a single millisecond to build time :) This is a major difference between the Next solution and Gatsby's solution.
@xthebumpx4 жыл бұрын
"Instead of optimizing images at build time, Next.js optimizes images on-demand, as users request them. Unlike static site generators and static-only solutions, your build times aren't increased, whether shipping 10 images or 10 million images." nextjs.org/docs/basic-features/image-optimization