Skip to content

Commit

Permalink
fix(gatsby-plugin-image): Apply inline styles and img size (#29603)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored Feb 19, 2021
1 parent 6bee561 commit 9db36db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/gatsby-plugin-image/src/components/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export function getWrapperProps(

let className = `gatsby-image-wrapper`

// If the plugin isn't installed we need to apply the styles inline
if (!global.GATSBY___IMAGE) {
wrapperStyle.position = `relative`
wrapperStyle.overflow = `hidden`
}

if (layout === `fixed`) {
wrapperStyle.width = width
wrapperStyle.height = height
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-plugin-image/src/components/lazy-hydrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export function lazyHydrate(
)}
<MainImage
{...(props as Omit<MainImageProps, "images" | "fallback">)}
width={width}
height={height}
className={imgClassName}
{...getMainProps(
isLoading,
Expand Down

0 comments on commit 9db36db

Please sign in to comment.