Gatsby Tutorial #16 - Optimized Images

  Рет қаралды 25,540

Net Ninja

Net Ninja

Күн бұрын

🐱‍💻 🐱‍💻 Course Files:
github.com/iam...
🐱‍👤🐱‍👤 JOIN THE GANG -
/ @netninja
🐱‍💻 🐱‍💻 My Udemy Courses:
Modern JavaScript - www.thenetninj...
Vue JS 3 & Firebase - www.thenetninj...
D3.js & Firebase - www.thenetninj...
🐱‍💻 🐱‍💻 Useful playlists:
Full React tutorial - • Full React Tutorial #1...
GraphQL tutorial - • GraphQL Tutorial #1 - ...
🐱‍💻 🐱‍💻 Other links:
Gatsby docs - www.gatsbyjs.c...
Markdown guide - guides.github....
Download Git - git-scm.com/do...
Get VS Code - code.visualstu...
🐱‍💻 🐱‍💻 Social Links:
Facebook - / thenetninjauk
Twitter - / thenetninjauk
Instagram - / thenetninja

Пікірлер: 68
@geraldmbuthia8780
@geraldmbuthia8780 3 жыл бұрын
For those who may struggle with creating a fluid image using gatsby-plugin-image , here is the code to ease your life. It fails to load at times, just give it time and resize your browser import { GatsbyImage, getImage } from "gatsby-plugin-image"; export const query = graphql` query Banner { file(relativePath: {eq: "banner.png"}) { childImageSharp { gatsbyImageData( layout: FULL_WIDTH placeholder: BLURRED formats: [AUTO, WEBP] ) } } } ` export default function Home({ data }) { console.log(data) const image = getImage(data.file.childImageSharp.gatsbyImageData) return ( Design Develop & Deploy UX designer & web developer based in Manchester. My Portfolio Projects ); }
@eluented
@eluented 2 жыл бұрын
thank you so much!
@elliothuntington8980
@elliothuntington8980 2 жыл бұрын
I'm still getting an error when using the graphql query in the GraphiQL explorer stating: "TypeError: Cannot destructure property 'width' of '(intermediate value)' as it is null."
@vrutiksurti3066
@vrutiksurti3066 2 жыл бұрын
I was badly stuck thanks brother @ Gerald Mbuthia
3 жыл бұрын
For who that doesn't want to spend half-hour to figure out the "new way" to do this because "Fixed" and "Fluid" are now DEPRECATED! - Install the plugins: npm install gatsby-plugin-image gatsby-plugin-sharp gatsby-transformer-sharp - Add them in your gatsby-config.js file: module.exports = { plugins: [ `gatsby-plugin-image`, `gatsby-plugin-sharp`, `gatsby-transformer-sharp`, // Needed for dynamic images { resolve: `gatsby-source-filesystem`, options: { name: `images`, path: `${__dirname}/src/images/`, }, }, // ... ], } - Create the Query (You can choose the layout value either FULL_WIDTH, CONSTRAINED or FIXED) export const query = graphql` query MyQuery { file(relativePath: { eq: "banner.png" }) { childImageSharp { gatsbyImageData(layout: FIXED) } } } ` - In your Component: import { GatsbyImage } from "gatsby-plugin-image" - And use the GastsbyImage as following: - Don't forget to pass the correct props to your component: const Home = ({ data }) => { // ... } I hope it helps someone to save time. :) [Source - Gatsby Docs](www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide/)
@chadmiller9379
@chadmiller9379 3 жыл бұрын
Thank you!
@jdubhman
@jdubhman 3 жыл бұрын
Thanks! 👍
@aaryansj8016
@aaryansj8016 3 жыл бұрын
Tysm ❤️😘
@Zephyr-tg9hu
@Zephyr-tg9hu 2 жыл бұрын
Thanks, you're the best!
@Magda-L114
@Magda-L114 Жыл бұрын
not all superheroes wear capes
@vladimirputindreadlockrast812
@vladimirputindreadlockrast812 Жыл бұрын
By this time the Gatsby 5'er will have experienced the program breaking upon each new plugin installation. The only thing I've been able to do to make it work is start over each time, new installation of web-warrior, and then at the very hello world beginning, install all the plugins right then and there, and then jump to copying Lesson #16 into the web-warrior folder. If there's a new plugin installation in Lesson #17, I will probably have to do it all over again.
@DiogoGDF
@DiogoGDF Жыл бұрын
This is so annoying! I'm having to do the same, one of the companies I'm working for is using Gatsby and I'm obligated to use it. I honestly wouldn't use it if I didn't have to.
@woofcode3383
@woofcode3383 3 жыл бұрын
Its great that it is deprecated so then we practice to read the docs and figure it out ourselves, like in the real world. At least seeing how he does it first really helps too. Thank You Shaun.
@woofcode3383
@woofcode3383 3 жыл бұрын
Hi Guys, SO I've learned to use the new plugins and it worked. But then I ran into problems with GraphiQL on lesson 17. so I tried to just use the deprecated plugin that Shaun is using, and.. So if you want to follow along till the end, just use the same plugin's as Shaun's. it still worked for me.
@henryherrera5043
@henryherrera5043 3 жыл бұрын
Hello! I really like your videos. Could you update the video to the new gatsby-plugin-image, please? It would be great! Thanks! Cheers!
@sergio_san
@sergio_san 3 жыл бұрын
Hello Shaun, great video! That is perfect for managing images the right way. Just a quick question here... what if we have SVG images? I guess we cannot use those plugins because SVGs are "not images", so... are we just fine using SVG images inside the "images" folder, without any plugin, since they are vectorial images? Is it already optimized, in terms of responsiveness, load times... 'fluidness' by using SVG images for logos and icons? Thanks in advance.
@ajefersonstiv
@ajefersonstiv 3 жыл бұрын
USING GatsbyImage && getImage Firts: import { GatsbyImage, getImage } from "gatsby-plugin-image" THEN: export const query = graphql` query img_qry { file(relativePath: {eq: "banner.png"}) { id childImageSharp { gatsbyImageData(/*here u can add some other properties or just REMOVE () and leave the keywork gatsbyImageData*/) } } } ` NEXT based on your props parameter: const imgsrc = getImage(data.file); FINALLY ** FOR MORE U CAN CHECK THE FULL DOCUMENTATION OF gatsby-plugin-image**
@livb4139
@livb4139 3 жыл бұрын
thanks
@ajefersonstiv
@ajefersonstiv 2 жыл бұрын
@@alkdsjfadsf sure! Can u give me a way to share it?
@jdubhman
@jdubhman 3 жыл бұрын
Dang, the new v3 Image has thrown a spanner in the works for me :(
@ai.aspirations
@ai.aspirations 10 ай бұрын
thanks for the tutorial. An update is required!
@zeytouna9611
@zeytouna9611 4 ай бұрын
how do you make an image wobble or shake a bit when you're scrolling up and down ? I've seen a lot of Websites where the images within shake a bit, like it's shifting up down , does anyone know?
@simonolivo3318
@simonolivo3318 3 жыл бұрын
if you have problems with the "gatsby-plugin-sharp" library, remove the node_modules folder from the root project and type: npm install
@hareeshagummani2389
@hareeshagummani2389 3 жыл бұрын
Expecting advanced nextjs tutorial
@davidnindorera5362
@davidnindorera5362 3 жыл бұрын
Dope tuto !!
@RoyerAdames
@RoyerAdames 3 жыл бұрын
Can you update the video with the new gatsby-plugin-image?
@xforeal-dj2jt
@xforeal-dj2jt 2 ай бұрын
The better way insert images is like documentation import { StaticImage } from "gatsby-plugin-image" export function Dino() { return }
@michalnowak2181
@michalnowak2181 2 жыл бұрын
thx
@muthukumar8009
@muthukumar8009 2 жыл бұрын
are there any other plugins for images instead of transformer-sharp and plugin-sharp
@RP-lf2jm
@RP-lf2jm 2 жыл бұрын
'gatsby-image' is deprecated and the replacement is 'gatsby-plugin-image'
@unknownman1
@unknownman1 3 жыл бұрын
Great
@Luke1000
@Luke1000 3 жыл бұрын
thumb does not have the option for a drop down menu.
@Luke1000
@Luke1000 3 жыл бұрын
also receiving this error: Field "thumb" must not have a selection since type "String" has no subfields.
@hareeshagummani2389
@hareeshagummani2389 3 жыл бұрын
Hey Img and type fluid is no longer supported In Gatsby v3
@charlesmontojo3960
@charlesmontojo3960 3 жыл бұрын
Still do
@ridl27
@ridl27 3 жыл бұрын
ty
@73dines
@73dines 3 жыл бұрын
Such a mess to get one image! :)
@ripplesr5655
@ripplesr5655 Жыл бұрын
I would never use gatsby on production at this point. Gatsby is full of bugs and impossible to develop site with this. Even though I love the whole concept of gatsby, unfortunately it has other potential security issues as well as constant bugs.
@dl_hines
@dl_hines 11 ай бұрын
I can't get it to compile no matter how far back I go in versioning. I have an older processor on my dev machine but none of them build correctly. It's a pain.
@ripplesr5655
@ripplesr5655 11 ай бұрын
@@dl_hines Horrible. Sadly had to move on to another time tested solution.
@sumukhakb2701
@sumukhakb2701 3 жыл бұрын
Make a single video instead of video series, so that you can get more views. It's really sad to see you're getting fewer views, which really hurts me. Because I learned a lot from your videos, and you deserve a lot. Also Expecting advanced next.js tutorial with authentication
@NetNinja
@NetNinja 3 жыл бұрын
I’ll be doing more next vids soon :). I enjoy doing series with multiple videos & over time it works out more views combined than just 1 vid so it’s ok :).
@sumukhakb2701
@sumukhakb2701 3 жыл бұрын
@@NetNinja Hope you get more views, you are the best.
@jandurcak8500
@jandurcak8500 3 жыл бұрын
I dont think its about the video as the viewers, some people just find this too complex so they will skip. This content is absolutely amazing, commig back if i need to clear up something.
@AntNZ
@AntNZ 3 жыл бұрын
@@NetNinja you are the man!
Gatsby Tutorial #17 - Featured Images
8:12
Net Ninja
Рет қаралды 18 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,9 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
7 Design Patterns EVERY Developer Should Know
23:09
ForrestKnight
Рет қаралды 324 М.
Why is every React site so slow?
13:52
Theo - t3․gg
Рет қаралды 171 М.
Gatsby Tutorial #12 - Markdown & Transformer Plugins
7:53
Net Ninja
Рет қаралды 26 М.
7 better ways to create a React app
7:08
Fireship
Рет қаралды 583 М.
Turn 2 Eggs Into Fluffy Japanese Soufflé Pancakes!
5:26
CookingAtHome
Рет қаралды 3,4 МЛН
TanStack Query - How to become a React Query God
28:56
Austin Davis
Рет қаралды 32 М.
What is Gatsby JS and Why Use It
8:18
Zac Gordon
Рет қаралды 163 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1,2 МЛН
How to Improve Performance in React with Code Splitting
9:55
PedroTech
Рет қаралды 214 М.