Skip to content

Commit

Permalink
[gatsby-image] Support image loading with JavaScript disabled (#3122)
Browse files Browse the repository at this point in the history
* [gatsby-image] Support image loading with JavaScript disabled

* [gatsby-image] Fix noscript element rendering order

* Update index.js

* Fix my unfix
  • Loading branch information
kripod authored and KyleAMathews committed Dec 13, 2017
1 parent dcf6b39 commit b2a0810
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/gatsby-image/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@ class Image extends React.Component {
}}
/>
)}

{/* Show the original image during server-side rendering if JavaScript is disabled */}
<noscript>
<Img
alt={alt}
title={title}
srcSet={image.srcSet}
src={image.src}
sizes={image.sizes}
/>
</noscript>
</div>
</div>
)
Expand Down Expand Up @@ -374,6 +385,18 @@ class Image extends React.Component {
}}
/>
)}

{/* Show the original image during server-side rendering if JavaScript is disabled */}
<noscript>
<Img
alt={alt}
title={title}
width={image.width}
height={image.height}
srcSet={image.srcSet}
src={image.src}
/>
</noscript>
</div>
</div>
)
Expand Down

0 comments on commit b2a0810

Please sign in to comment.