Skip to content

Commit 0a1eec4

Browse files
ascorbicgatsbybot
and
gatsbybot
authoredOct 15, 2020
docs(gatsby-plugin-image): Update now we know min gatsby version (#27473)
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
1 parent 6abef2c commit 0a1eec4

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed
 

‎packages/gatsby-plugin-image/README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
This plugin is a replacement for gatsby-image. It adds [static images](#static-images), and a [new higher-performance gatsby-image component](#gatsby-image-next-generation).
44

5-
This package is in alpha, and the API will change. It is not ready for production use yet.
5+
This package is in alpha, and the API will change. It is not ready for production use yet, but feedback would be great.
66

77
## Usage
88

9-
Install `gatsby-plugin-image`, then add it to your `gatsby-config.js`.
9+
Install `gatsby-plugin-image` and `gatsby-plugin-sharp`, then add them to your `gatsby-config.js`. Upgrade `gatsby` to at least `2.24.78`.
1010

1111
# Static images
1212

13-
The [gatsby-image](https://www.gatsbyjs.org/packages/gatsby-image/) component, combined with the sharp plugin, is a great way to automatically resize and optimize your images and serve them in the most performant way. This plugin is a proof of concept for a simpler way to use Gatsby's image processing tools without needing to write GraphQL queries. It is designed for static images such as logos rather than ones loaded dynamically from a CMS.
13+
This plugin is a proof of concept for a simpler way to use Gatsby's image processing tools and components without needing to write GraphQL queries. It is designed for static images such as logos rather than ones loaded dynamically from a CMS.
1414

1515
The current way to do this is with `useStaticQuery`:
1616

@@ -58,8 +58,6 @@ export const Dino = () => (
5858
<StaticImage
5959
src="trex.png"
6060
base64={false}
61-
fluid
62-
webP
6361
grayscale
6462
maxWidth={200}
6563
alt="T-Rex"
@@ -109,7 +107,7 @@ The props must be able to be statically-analyzed at build time. You can't pass t
109107
//Doesn't work
110108
() => {
111109
const width = getTheWidthFromSomewhere();
112-
return <Img src="trex-png" width={width}>
110+
return <Img src="trex.png" width={width}>
113111
}
114112
```
115113
@@ -119,7 +117,7 @@ You can use variables and expressions if they're in the scope of the file, e.g.:
119117
//OK
120118
() => {
121119
const width = 300
122-
return <Img src="trex-png" width={width}>
120+
return <Img src="trex.png" width={width}>
123121
}
124122
```
125123
@@ -130,7 +128,7 @@ const width = 300
130128

131129
() => {
132130
const height = width * 16 / 9
133-
return <Img src="trex-png" width={width} height={height}>
131+
return <Img src="trex.png" width={width} height={height}>
134132
}
135133
```
136134
@@ -155,7 +153,7 @@ module.exports = {
155153
156154
### API
157155
158-
The only required prop is `src`. The default type is `fixed`.
156+
The only required prop is `src`. The default type is `fixed`. The other props match those of [the new GatsbyImage component](#gatsby-image-next-generation)
159157
160158
## gatsby-image next generation
161159

‎packages/gatsby-plugin-image/src/babel-plugin-parse-static-images.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from "path"
66
import { slash } from "gatsby-core-utils"
77

88
import template from "@babel/template"
9+
import { stripIndent } from "common-tags"
910

1011
/**
1112
* This is a plugin that finds StaticImage components and injects the image props into the component.
@@ -63,9 +64,12 @@ export default function attrs({
6364
data = fs.readJSONSync(filename)
6465
} catch (e) {
6566
// TODO add info about minimum Gatsby version once this is merged
66-
console.warn(
67-
`[gatsby-plugin-image] Could not read image data file "${filename}". This may mean that the images in "${this.filename}" were not processed.`
68-
)
67+
const msg = stripIndent`
68+
Could not read image data file "${filename}".
69+
This may mean that the images in "${this.filename}" were not processed.
70+
Please ensure that your gatsby version is at least 2.24.78.`
71+
error += msg
72+
console.warn(`[gatsby-plugin-image] ${msg}`)
6973
}
7074
}
7175

‎packages/gatsby-plugin-image/src/components/static-image.server.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function _getStaticImage(
7373
console.warn(`Image not loaded`, src)
7474
if (!__error && process.env.NODE_ENV === `development`) {
7575
console.warn(
76-
`Please ensure that "gatsby-plugin-image" is included in the plugins array in gatsby-config.js`
76+
`Please ensure that "gatsby-plugin-image" is included in the plugins array in gatsby-config.js, and that your version of gatsby is at least 2.24.78`
7777
)
7878
}
7979
return null

0 commit comments

Comments
 (0)
Please sign in to comment.