Skip to content

Commit

Permalink
fix(gatsby-plugin-image): pass down missing sizes attribute to <sourc…
Browse files Browse the repository at this point in the history
…es> (#29092) (#29108)

(cherry picked from commit 2e42197)

Co-authored-by: Adrien Denat <adrien.denat@gmail.com>
  • Loading branch information
GatsbyJS Bot and Grsmto committed Jan 20, 2021
1 parent fbc5893 commit 8599f60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/gatsby-plugin-image/src/components/picture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ const Image: FunctionComponent<ImageProps> = function Image({

export const Picture = forwardRef<HTMLImageElement, PictureProps>(
function Picture(
{ fallback, sources = [], shouldLoad = true, ...props },
{ fallback, sources = [], shouldLoad = true, sizes, ...props },
ref
) {
const fallbackImage = (
<Image {...props} {...fallback} shouldLoad={shouldLoad} innerRef={ref} />
<Image
sizes={sizes}
{...props}
{...fallback}
shouldLoad={shouldLoad}
innerRef={ref}
/>
)

if (!sources.length) {
Expand All @@ -85,6 +91,7 @@ export const Picture = forwardRef<HTMLImageElement, PictureProps>(
type={type}
media={media}
srcSet={srcSet}
sizes={sizes}
/>
))}
{fallbackImage}
Expand Down

0 comments on commit 8599f60

Please sign in to comment.