From 9d9ab2f01fad1f5e4a2036e8c7c28d0ee8d6746e Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 23 Aug 2022 14:06:49 +0800 Subject: [PATCH] fix(#39807): ignore width/height from webpack with "fill" --- packages/next/client/future/image.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/next/client/future/image.tsx b/packages/next/client/future/image.tsx index 4ca2d06ec3c55c7..f3ffe5b7033edb2 100644 --- a/packages/next/client/future/image.tsx +++ b/packages/next/client/future/image.tsx @@ -591,8 +591,11 @@ export default function Image({ blurDataURL = blurDataURL || staticImageData.blurDataURL staticSrc = staticImageData.src - height = height || staticImageData.height - width = width || staticImageData.width + // Ignore width and height (come from the bundler) when "fill" is used + if (!fill) { + height = height || staticImageData.height + width = width || staticImageData.width + } if (!staticImageData.height || !staticImageData.width) { throw new Error( `An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(