Skip to content

Commit 76b9827

Browse files
patrickcameronpieh
authored andcommitted
feat(gatsby-image): add itemProp prop (#11296)
1 parent 8d288c7 commit 76b9827

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

packages/gatsby-image/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface GatsbyImageProps {
4040
onStartLoad?: (param: { wasCached: boolean }) => void
4141
onError?: (event: any) => void
4242
Tag?: string
43+
itemProp?: string
4344
}
4445

4546
export default class GatsbyImage extends React.Component<

packages/gatsby-image/src/__tests__/__snapshots__/index.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exports[`<Img /> should render fixed size images 1`] = `
2828
<img
2929
alt="Alt text for the image"
3030
height="100"
31+
itemprop="item-prop-for-the-image"
3132
src="test_image.jpg"
3233
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; opacity: 0;"
3334
title="Title for the image"
@@ -73,6 +74,7 @@ exports[`<Img /> should render fluid images 1`] = `
7374
/>
7475
<img
7576
alt="Alt text for the image"
77+
itemprop="item-prop-for-the-image"
7678
src="test_image.jpg"
7779
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; opacity: 0;"
7880
title="Title for the image"

packages/gatsby-image/src/__tests__/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const setup = (fluid = false, onLoad = () => {}, onError = () => {}) => {
3535
{...!fluid && { fixed: fixedShapeMock }}
3636
onLoad={onLoad}
3737
onError={onError}
38+
itemProp={`item-prop-for-the-image`}
3839
placeholderStyle={{ color: `red` }}
3940
placeholderClassName={`placeholder`}
4041
/>

packages/gatsby-image/src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class Image extends React.Component {
227227
fixed,
228228
backgroundColor,
229229
Tag,
230+
itemProp,
230231
} = convertProps(this.props)
231232

232233
const bgColor =
@@ -323,6 +324,7 @@ class Image extends React.Component {
323324
ref={this.imageRef}
324325
onLoad={this.handleImageLoaded}
325326
onError={this.props.onError}
327+
itemProp={itemProp}
326328
/>
327329
</picture>
328330
)}
@@ -408,6 +410,7 @@ class Image extends React.Component {
408410
ref={this.imageRef}
409411
onLoad={this.handleImageLoaded}
410412
onError={this.props.onError}
413+
itemProp={itemProp}
411414
/>
412415
</picture>
413416
)}
@@ -482,6 +485,7 @@ Image.propTypes = {
482485
onError: PropTypes.func,
483486
onStartLoad: PropTypes.func,
484487
Tag: PropTypes.string,
488+
itemProp: PropTypes.string,
485489
}
486490

487491
export default Image

0 commit comments

Comments
 (0)