Install gatsby-image and source local images from the filesystem

Kyle Gill
InstructorKyle Gill
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

Learn how to install and setup gatsby-image plugins to source local images from the filesystem so you can query them with GraphQL, and then use them in your site.

Instructor: [00:00] In order to use the Gatsby Image component, you'll need to install the package. Run npm install --save gatsby-image.

[00:07] 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.

[00:20] 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.

[00:41] 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.