From 95cabd9c346e4f6239edd420d94d4a60174639d1 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Fri, 19 Feb 2021 12:48:38 +0000 Subject: [PATCH] fix(gatsby-plugin-image): Apply inline styles and img size --- packages/gatsby-plugin-image/src/components/hooks.ts | 6 ++++++ .../gatsby-plugin-image/src/components/lazy-hydrate.tsx | 2 ++ 2 files changed, 8 insertions(+) diff --git a/packages/gatsby-plugin-image/src/components/hooks.ts b/packages/gatsby-plugin-image/src/components/hooks.ts index 810f939471d8e..0dad1518a7624 100644 --- a/packages/gatsby-plugin-image/src/components/hooks.ts +++ b/packages/gatsby-plugin-image/src/components/hooks.ts @@ -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 diff --git a/packages/gatsby-plugin-image/src/components/lazy-hydrate.tsx b/packages/gatsby-plugin-image/src/components/lazy-hydrate.tsx index 3cff538bc7c88..65e232291e8f7 100644 --- a/packages/gatsby-plugin-image/src/components/lazy-hydrate.tsx +++ b/packages/gatsby-plugin-image/src/components/lazy-hydrate.tsx @@ -84,6 +84,8 @@ export function lazyHydrate( )} )} + width={width} + height={height} className={imgClassName} {...getMainProps( isLoading,