Skip to content

Commit aa8b2fb

Browse files
jamessimonewardpeet
authored andcommitted
fix(gatsby-image): add itemprop on placeholder images (#18035)
* Fixes #17419 and a logging issue generated by no key value for the recipe-gatsby-image when running gatsby repo tests * Fixing mapping prop to appropriately use key in order to suppress warning when running tests
1 parent b3774a2 commit aa8b2fb

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

examples/recipes-gatsby-image/src/pages/examples/directory.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ export default () => {
4242

4343
return (
4444
<Layout>
45-
{images.map(image => (
45+
{images.map((image, index) => (
4646
<Img
47+
key={index}
4748
fluid={image.node.childImageSharp.fluid}
4849
alt={image.node.base.split(`.`)[0]}
4950
/>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exports[`<Image /> should have a transition-delay of 1sec 1`] = `
1313
<img
1414
alt=""
1515
class="placeholder"
16+
itemprop="item-prop-for-the-image"
1617
src="string_of_base64"
1718
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 1; transition-delay: 1000ms; color: red;"
1819
title="Title for the image"
@@ -59,6 +60,7 @@ exports[`<Image /> should render fixed size images 1`] = `
5960
<img
6061
alt=""
6162
class="placeholder"
63+
itemprop="item-prop-for-the-image"
6264
src="string_of_base64"
6365
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 1; transition-delay: 500ms; color: red;"
6466
title="Title for the image"
@@ -108,6 +110,7 @@ exports[`<Image /> should render fluid images 1`] = `
108110
<img
109111
alt=""
110112
class="placeholder"
113+
itemprop="item-prop-for-the-image"
111114
src="string_of_base64"
112115
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 1; transition-delay: 500ms; color: red;"
113116
title="Title for the image"
@@ -163,6 +166,7 @@ exports[`<Image /> should render multiple fixed image variants 1`] = `
163166
<img
164167
alt=""
165168
class="placeholder"
169+
itemprop="item-prop-for-the-image"
166170
src="other_string_of_base64"
167171
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 1; transition-delay: 500ms; color: red;"
168172
title="Title for the image"
@@ -229,6 +233,7 @@ exports[`<Image /> should render multiple fluid image variants 1`] = `
229233
<img
230234
alt=""
231235
class="placeholder"
236+
itemprop="item-prop-for-the-image"
232237
src="string_of_base64"
233238
style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 1; transition-delay: 500ms; color: red;"
234239
title="Title for the image"

packages/gatsby-image/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ class Image extends React.Component {
411411
alt: !this.state.isVisible ? alt : ``,
412412
style: imagePlaceholderStyle,
413413
className: placeholderClassName,
414+
itemProp,
414415
}
415416

416417
if (fluid) {

0 commit comments

Comments
 (0)