Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Install gatsby-image and source local images from the filesystem


    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.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    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.