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
…29668)

(cherry picked from commit 9db36db)

Co-authored-by: Matt Kane <matt@gatsbyjs.com>
  • Loading branch information
GatsbyJS Bot and ascorbic committed Feb 23, 2021
1 parent 2625159 commit 9183a6b
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
Expand Up @@ -60,6 +60,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
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 9183a6b

Please sign in to comment.