Instructor: In order to use the Gatsby Image component, you'll need to install the package. Run npm install --save gatsby-image.
Gatsby Image requires you to pass in image data, generally provided by a plug-in. To source images from the filesystem, you'll need several additional plugins. Install gatsby-source-filesystem, gatsby-plugin-sharp, and gatsby-transformer-sharp.
The sharp and filesystem plugins need to be included in the Gatsby config. The sharp plugins don't need any configurations, so you can include them as strings. The filesystem plugin needs to be told where the images are, in my case, in source images.
Now, restarting the server will include the images in the GraphQL data layer as image sharp nodes. You can actually see the optimized image files Gatsby's using in the public folder if you navigate through it.
You must be a Pro Member to view code
Access all courses and lessons, track your progress, gain confidence and expertise.