Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-image): Fix handling of sizes prop in SSR #28835

Merged
merged 9 commits into from
Jan 5, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const GatsbyImage: FunctionComponent<GatsbyImageProps> = function GatsbyI
layout,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
layout,
layout,
fallback,

images,
placeholder,
sizes,
backgroundColor: placeholderBackgroundColor,
} = image

Expand All @@ -65,7 +64,7 @@ export const GatsbyImage: FunctionComponent<GatsbyImageProps> = function GatsbyI
}
if (images.fallback) {
cleanedImages.fallback = {
src: images.fallback.src,
...images.fallback,
Comment on lines 65 to +67
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (images.fallback) {
cleanedImages.fallback = {
src: images.fallback.src,
...images.fallback,
if (fallback) {
cleanedImages.fallback = {
...fallback,

srcSet: images.fallback.srcSet
? removeNewLines(images.fallback.srcSet)
: undefined,
Expand Down Expand Up @@ -106,7 +105,6 @@ export const GatsbyImage: FunctionComponent<GatsbyImageProps> = function GatsbyI

<MainImage
data-gatsby-image-ssr=""
sizes={sizes}
className={imgClassName}
style={imgStyle}
{...(props as Omit<MainImageProps, "images" | "fallback">)}
Expand Down