@@ -254,8 +254,14 @@ const noscriptImg = props => {
254254// Earlier versions of gatsby-image during the 2.x cycle did not wrap
255255// the `Img` component in a `picture` element. This maintains compatibility
256256// until a breaking change can be introduced in the next major release
257- const Placeholder = ( { src, imageVariants, generateSources, spreadProps } ) => {
258- const baseImage = < Img src = { src } { ...spreadProps } />
257+ const Placeholder = ( {
258+ src,
259+ imageVariants,
260+ generateSources,
261+ spreadProps,
262+ ariaHidden,
263+ } ) => {
264+ const baseImage = < Img src = { src } { ...spreadProps } ariaHidden = { ariaHidden } />
259265
260266 return imageVariants . length > 1 ? (
261267 < picture >
@@ -277,11 +283,14 @@ const Img = React.forwardRef((props, ref) => {
277283 onError,
278284 loading,
279285 draggable,
286+ // `ariaHidden`props is used to exclude placeholders from the accessibility tree.
287+ ariaHidden,
280288 ...otherProps
281289 } = props
282290
283291 return (
284292 < img
293+ aria-hidden = { ariaHidden }
285294 sizes = { sizes }
286295 srcSet = { srcSet }
287296 src = { src }
@@ -467,6 +476,7 @@ class Image extends React.Component {
467476 >
468477 { /* Preserve the aspect ratio. */ }
469478 < Tag
479+ aria-hidden
470480 style = { {
471481 width : `100%` ,
472482 paddingBottom : `${ 100 / image . aspectRatio } %` ,
@@ -476,6 +486,7 @@ class Image extends React.Component {
476486 { /* Show a solid background color. */ }
477487 { bgColor && (
478488 < Tag
489+ aria-hidden
479490 title = { title }
480491 style = { {
481492 backgroundColor : bgColor ,
@@ -493,6 +504,7 @@ class Image extends React.Component {
493504 { /* Show the blurry base64 image. */ }
494505 { image . base64 && (
495506 < Placeholder
507+ ariaHidden
496508 src = { image . base64 }
497509 spreadProps = { placeholderImageProps }
498510 imageVariants = { imageVariants }
@@ -503,6 +515,7 @@ class Image extends React.Component {
503515 { /* Show the traced SVG image. */ }
504516 { image . tracedSVG && (
505517 < Placeholder
518+ ariaHidden
506519 src = { image . tracedSVG }
507520 spreadProps = { placeholderImageProps }
508521 imageVariants = { imageVariants }
@@ -577,6 +590,7 @@ class Image extends React.Component {
577590 { /* Show a solid background color. */ }
578591 { bgColor && (
579592 < Tag
593+ aria-hidden
580594 title = { title }
581595 style = { {
582596 backgroundColor : bgColor ,
@@ -591,6 +605,7 @@ class Image extends React.Component {
591605 { /* Show the blurry base64 image. */ }
592606 { image . base64 && (
593607 < Placeholder
608+ ariaHidden
594609 src = { image . base64 }
595610 spreadProps = { placeholderImageProps }
596611 imageVariants = { imageVariants }
@@ -601,6 +616,7 @@ class Image extends React.Component {
601616 { /* Show the traced SVG image. */ }
602617 { image . tracedSVG && (
603618 < Placeholder
619+ ariaHidden
604620 src = { image . tracedSVG }
605621 spreadProps = { placeholderImageProps }
606622 imageVariants = { imageVariants }
0 commit comments