{"id":28005,"date":"2022-03-24T20:10:44","date_gmt":"2022-03-24T20:10:44","guid":{"rendered":"http:\/\/using-static-image-in-gatsby-plugin-image"},"modified":"2025-02-22T13:42:24","modified_gmt":"2025-02-22T21:42:24","slug":"using-static-image-in-gatsby-plugin-image","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/","title":{"rendered":"Using static image in Gatsby-plugin-image"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>It can be challenging to manually add responsive images to our site while retaining excellent performance rankings. The Gatsby Image plugin takes care of the difficult elements of creating images in a variety of sizes and formats.<\/p>\n<p>This article will discuss how to use hosted and local images in Gatsby applications using the <code>StaticImage<\/code> component of the <code>gatsby-plugin-image<\/code> module.<\/p>\n<h1>Sandbox<\/h1>\n<p>This project was completed in a <a href=\"https:\/\/codesandbox.io\/s\/using-static-image-in-gatsby-plugin-image-vrfo5c\">Codesandbox<\/a>. To get started quickly, fork the <a href=\"https:\/\/codesandbox.io\/s\/using-static-image-in-gatsby-plugin-image-vrfo5c\">Codesandbox<\/a> or run the project.<\/p>\n<\/div>\n\n\n  <div class=\"wp-block-cloudinary-code-sandbox \">\n    <iframe\n      src=\"https:\/\/codesandbox.io\/embed\/using-static-image-in-gatsby-plugin-image-vrfo5c?theme=dark&amp;codemirror=1&amp;highlights=&amp;editorsize=50&amp;fontsize=14&amp;expanddevtools=0&amp;hidedevtools=0&amp;eslint=0&amp;forcerefresh=0&amp;hidenavigation=0&amp;initialpath=%2F&amp;module=&amp;moduleview=0&amp;previewwindow=&amp;view=&amp;runonclick=1\"\n      height=\"500\"\n      style=\"width: 100%;\"\n      title=\"Using static image in Gatsby-plugin-image\"\n      loading=\"lazy\"\n      allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n      sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n    ><\/iframe>\n  <\/div>\n\n\n<div class=\"wp-block-cloudinary-markdown \"><p>GitHub Repository:<\/p>\n<p><a href=\"https:\/\/github.com\/Olanetsoft\/static-image-with-gatsby-plugin-image\">https:\/\/github.com\/Olanetsoft\/static-image-with-gatsby-plugin-image<\/a><\/p>\n<h1>Prerequisite<\/h1>\n<ul>\n<li>The knowledge of JavaScript and React.js<\/li>\n<li>The knowledge of Gatsby.js is not required but preferred.<\/li>\n<li>Gatsby CLI should be installed globally. Learn how to install it <a href=\"https:\/\/www.gatsbyjs.com\/docs\/reference\/gatsby-cli\/\">here<\/a>.<\/li>\n<\/ul>\n<h1>Getting Started with Gatsby<\/h1>\n<p><a href=\"https:\/\/www.gatsbyjs.com\/docs\/quick-start\/\">Gatsby<\/a> is an open-source static site generator (SSG). Gatsby uses efficient pre-configuration for rapid page loads, code splitting, server-side rendering, intelligent image loading, asset optimization, and data prefetching.<\/p>\n<p>Gatsby uses <a href=\"https:\/\/webpack.js.org\/\">webpack<\/a>, <a href=\"https:\/\/graphql.org\/\">G<\/a><a href=\"https:\/\/graphql.org\/\">raphQL<\/a> and <a href=\"https:\/\/reactjs.org\/\">React.js<\/a> to build and render high-performance web apps. Gatsby can also create progressive web apps that adhere to the current web standards and are designed for speed and security.<\/p>\n<h1>Why Gatsby <code>StaticImage<\/code> Component?<\/h1>\n<p>Using the native HTML\u2019s  <code>img<\/code> tag to render images on a web page requires a lot of logic to serve an optimized version.\nHowever, the framework\u2019s approach to handling and optimizing images makes Gatsby.js webpages lightning fast. The <code>gatsby-plugin-image<\/code> component is a React component that works with Gatsby.js\u2019 native image processing capabilities, which are powered by GraphQL and <code>gatsby-plugin-sharp<\/code>.<\/p>\n<h1>Creating a new project and Installing Dependencies<\/h1>\n<p>To create a new project, we use the <code>gatsby new<\/code> <code>&lt;project name&gt;<\/code> command to scaffold a new project.<\/p>\n<p>To start our application, we run the following command.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    cd <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">project<\/span> <span class=\"hljs-attr\">name<\/span>&gt;<\/span>\n    npm run develop\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Once the app is initialized, and the dependencies installed, we see instructions for navigating to our site and running it locally.<\/p>\n<p>Gatsby will start a hot-reloading development environment accessible by default at <a href=\"http:\/\/localhost:4000\">http:\/\/localhost:<\/a>8000<\/p>\n<blockquote>\n<p>For our local development server to pick up the new modifications after changing our <code>gatsby-config.js<\/code> file, we must restart it. It will sometimes restart automatically, but if we see any unusual behaviour, we will attempt restarting it manually.<\/p>\n<\/blockquote>\n<h1>Building our project<\/h1>\n<p>In the previous step, we installed and configured the gatsby-plugin-image plugin that ships with the default gatsby setup. Now we can use the <code>StaticImage<\/code> component in our Gatsby site like we would use an <code>&lt;img&gt;<\/code> element in HTML.<\/p>\n<p>We will update <code>pages\/index.js<\/code> file with the following code snippet:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">import<\/span> * <span class=\"hljs-keyword\">as<\/span> React <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react\"<\/span>\n    <span class=\"hljs-keyword\">import<\/span> { StaticImage } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"gatsby-plugin-image\"<\/span>\n    <span class=\"hljs-keyword\">import<\/span> Layout <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"..\/components\/layout\"<\/span>\n    <span class=\"hljs-keyword\">import<\/span> Seo <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"..\/components\/seo\"<\/span>\n    \n    <span class=\"hljs-keyword\">const<\/span> IndexPage = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> (\n      <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Layout<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Seo<\/span> <span class=\"hljs-attr\">title<\/span>=<span class=\"hljs-string\">\"Home\"<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>A Demo Using static image in Gatsby-plugin-image<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h3<\/span>&gt;<\/span>StaticImage plugin using photo from local filesystem<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h3<\/span>&gt;<\/span>\n         \/\/ ...\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Layout<\/span>&gt;<\/span><\/span>\n    )\n    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> IndexPage\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>We will render our <code>StaticImage<\/code> plugin from <code>gatsby-plugin-image<\/code> module. Since we will be rendering images from our local file system, let us download a photo to our computer and save it in our project folder.<\/p>\n<p>We\u2019ll place it in the <code>src\/images<\/code> directory to keep everything tidy.<\/p>\n<p>Before we proceed to render the StaticImage component, it expects the following props:<\/p>\n<ul>\n<li>\n<code>src<\/code>: The URL to the image we want to load. (This is the same as what you put in the src attribute of an HTML element.)<\/li>\n<li>\n<code>placeholder<\/code>: Style of the temporary image shown while the full image loads.<\/li>\n<li>\n<code>alt<\/code>: alt text to describe the image. It\u2019s also used by screen readers or a problem loading the image.<\/li>\n<li>\n<code>width<\/code>: The width of the image.<\/li>\n<li>\n<code>height<\/code>: The height of the image.<\/li>\n<li>\n<code>quality<\/code>: Setting the quality of the image.<\/li>\n<li>\n<code>transformOptions<\/code>: Options to sharpen, control cropping, and other image manipulations.<\/li>\n<li>\n<code>formats<\/code>: File formats of the images generated.<\/li>\n<\/ul>\n<p>There are also advanced image processing options available. We can find the complete list of options <a href=\"https:\/\/www.gatsbyjs.com\/docs\/reference\/built-in-components\/gatsby-plugin-image\">in the API docs<\/a>.<\/p>\n<p>Let us update the <code>pages\/index.js<\/code> file with the following code snippet:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-comment\">\/\/ ...<\/span>\n    \n    <span class=\"hljs-keyword\">const<\/span> IndexPage = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> (\n      <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Layout<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Seo<\/span> <span class=\"hljs-attr\">title<\/span>=<span class=\"hljs-string\">\"Home\"<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>A Demo Using static image in Gatsby-plugin-image<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h3<\/span>&gt;<\/span>StaticImage plugin using photo from local filesystem<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h3<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">StaticImage<\/span>\n          <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"..\/images\/beautiful-dog.jpeg\"<\/span>\n          <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\">\"blurred\"<\/span>\n          <span class=\"hljs-attr\">width<\/span>=<span class=\"hljs-string\">{600}<\/span>\n          <span class=\"hljs-attr\">height<\/span>=<span class=\"hljs-string\">{600}<\/span>\n          <span class=\"hljs-attr\">formats<\/span>=<span class=\"hljs-string\">{&#91;<\/span>\"<span class=\"hljs-attr\">auto<\/span>\", \"<span class=\"hljs-attr\">webp<\/span>\", \"<span class=\"hljs-attr\">avif<\/span>\"]}\n          <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"A Dog Image\"<\/span>\n          <span class=\"hljs-attr\">transformOptions<\/span>=<span class=\"hljs-string\">{{<\/span> <span class=\"hljs-attr\">fit:<\/span> \"<span class=\"hljs-attr\">cover<\/span>\", <span class=\"hljs-attr\">cropFocus:<\/span> \"<span class=\"hljs-attr\">attention<\/span>\" }}\n        \/&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Layout<\/span>&gt;<\/span><\/span>\n    )\n    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> IndexPage\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the code snippet above, we set the src prop to our local file image added earlier in the <code>src\/images<\/code>. Our application should look similar to what we have below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_2582471303BC8E056CEDF5A40BF94F1F88F0B0A9395ECE02AF5DDBFD6B2CC35F_1645742967177_Screenshot+2022-02-24+at+23.48.46.png\" alt=\"Gatsby - Static Image\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"1125\"\/><\/p>\n<p>Next, we will change the <code>src<\/code> of our image to use a Cloudinary hosted image URL. We will add quality props to override the default format-specific options.<\/p>\n<p>We will update <code>pages\/index.js<\/code> file with the following code snippet:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-comment\">\/\/ ...<\/span>\n    \n    <span class=\"hljs-keyword\">const<\/span> IndexPage = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> (\n      <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Layout<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Seo<\/span> <span class=\"hljs-attr\">title<\/span>=<span class=\"hljs-string\">\"Home\"<\/span> \/&gt;<\/span>\n    \n        \/\/ ...\n    \n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h3<\/span>&gt;<\/span>StaticImage plugin using photo from image URL online<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h3<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">StaticImage<\/span>\n          <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/olanetsoft\/image\/upload\/v1554336410\/samples\/bike.jpg\"<\/span>\n          <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\">\"blurred\"<\/span>\n          <span class=\"hljs-attr\">width<\/span>=<span class=\"hljs-string\">{600}<\/span>\n          <span class=\"hljs-attr\">height<\/span>=<span class=\"hljs-string\">{600}<\/span>\n          <span class=\"hljs-attr\">formats<\/span>=<span class=\"hljs-string\">{&#91;<\/span>\"<span class=\"hljs-attr\">auto<\/span>\", \"<span class=\"hljs-attr\">webp<\/span>\", \"<span class=\"hljs-attr\">avif<\/span>\"]}\n          <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"A Dog Image\"<\/span>\n          <span class=\"hljs-attr\">transformOptions<\/span>=<span class=\"hljs-string\">{{<\/span> <span class=\"hljs-attr\">fit:<\/span> \"<span class=\"hljs-attr\">cover<\/span>\", <span class=\"hljs-attr\">cropFocus:<\/span> \"<span class=\"hljs-attr\">attention<\/span>\" }}\n          <span class=\"hljs-attr\">quality<\/span>=<span class=\"hljs-string\">{90}<\/span>\n        \/&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Layout<\/span>&gt;<\/span><\/span>\n    )\n    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> IndexPage\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Testing our application<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_2582471303BC8E056CEDF5A40BF94F1F88F0B0A9395ECE02AF5DDBFD6B2CC35F_1645744311080_Screenshot+2022-02-25+at+00.11.10.png\" alt=\"Gatsby - Static Image\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"963\"\/><\/p>\n<h1>Conclusion<\/h1>\n<p>In this article, we learned how to use the <code>StaticImage<\/code> component of the <code>gatsby-plugin-image<\/code> module. We also learned how to render hosted and local image files.<\/p>\n<h1>Resources<\/h1>\n<ul>\n<li>[Static Image API docs](<a href=\"http:\/\/using\">http:\/\/using<\/a> the StaticImage component of the gatsby-plugin-image module.)<\/li>\n<li>\n<a href=\"https:\/\/gatsbyjs.com\/\">Gatsby.js<\/a>\n<\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":28006,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[378,134,370,246,371,373],"class_list":["post-28005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-gatsbyjs","tag-guest-post","tag-image","tag-react","tag-under-review","tag-upload"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Using static image in Gatsby-plugin-image<\/title>\n<meta name=\"description\" content=\"In this article, we learned how to use the `StaticImage` component of the `gatsby-plugin-image` module. We also learned how to render hosted and local image files.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using static image in Gatsby-plugin-image\" \/>\n<meta property=\"og:description\" content=\"In this article, we learned how to use the `StaticImage` component of the `gatsby-plugin-image` module. We also learned how to render hosted and local image files.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-24T20:10:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-22T21:42:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213-jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"6000\" \/>\n\t<meta property=\"og:image:height\" content=\"4000\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Using static image in Gatsby-plugin-image\",\"datePublished\":\"2022-03-24T20:10:44+00:00\",\"dateModified\":\"2025-02-22T21:42:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/\"},\"wordCount\":5,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA\",\"keywords\":[\"GatsbyJS\",\"Guest Post\",\"Image\",\"React\",\"Under Review\",\"Upload\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\",\"name\":\"Using static image in Gatsby-plugin-image\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA\",\"datePublished\":\"2022-03-24T20:10:44+00:00\",\"dateModified\":\"2025-02-22T21:42:24+00:00\",\"description\":\"In this article, we learned how to use the `StaticImage` component of the `gatsby-plugin-image` module. We also learned how to render hosted and local image files.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA\",\"width\":6000,\"height\":4000},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using static image in Gatsby-plugin-image\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Using static image in Gatsby-plugin-image","description":"In this article, we learned how to use the `StaticImage` component of the `gatsby-plugin-image` module. We also learned how to render hosted and local image files.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image","og_locale":"en_US","og_type":"article","og_title":"Using static image in Gatsby-plugin-image","og_description":"In this article, we learned how to use the `StaticImage` component of the `gatsby-plugin-image` module. We also learned how to render hosted and local image files.","og_url":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image","og_site_name":"Cloudinary Blog","article_published_time":"2022-03-24T20:10:44+00:00","article_modified_time":"2025-02-22T21:42:24+00:00","og_image":[{"width":6000,"height":4000,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213-jpg?_i=AA","type":"image\/jpeg"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/"},"author":{"name":"","@id":""},"headline":"Using static image in Gatsby-plugin-image","datePublished":"2022-03-24T20:10:44+00:00","dateModified":"2025-02-22T21:42:24+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/"},"wordCount":5,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA","keywords":["GatsbyJS","Guest Post","Image","React","Under Review","Upload"],"inLanguage":"en-US","copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image\/","url":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image","name":"Using static image in Gatsby-plugin-image","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA","datePublished":"2022-03-24T20:10:44+00:00","dateModified":"2025-02-22T21:42:24+00:00","description":"In this article, we learned how to use the `StaticImage` component of the `gatsby-plugin-image` module. We also learned how to render hosted and local image files.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA","width":6000,"height":4000},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/using-static-image-in-gatsby-plugin-image#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using static image in Gatsby-plugin-image"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925697\/Web_Assets\/blog\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213\/db09360201e9a7f453f756c8ad6d10294dec0425-6000x4000-1_28006cd213.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=28005"}],"version-history":[{"count":2,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28005\/revisions"}],"predecessor-version":[{"id":36946,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28005\/revisions\/36946"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/28006"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=28005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=28005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=28005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}