From 2a769161e19f4ca82ea493d490bc2ff55febc0df Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 15 Sep 2022 01:45:38 +0200 Subject: [PATCH 1/3] Update next-image-loader.js --- .../build/webpack/loaders/next-image-loader.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-image-loader.js b/packages/next/build/webpack/loaders/next-image-loader.js index 6bc17aa92ebfddd..0f264c2dc93d061 100644 --- a/packages/next/build/webpack/loaders/next-image-loader.js +++ b/packages/next/build/webpack/loaders/next-image-loader.js @@ -35,12 +35,18 @@ function nextImageLoader(content) { // Shrink the image's largest dimension if (imageSize.width >= imageSize.height) { blurWidth = BLUR_IMG_SIZE - blurHeight = Math.round( - (imageSize.height / imageSize.width) * BLUR_IMG_SIZE + blurHeight = Math.max( + Math.round( + (imageSize.height / imageSize.width) * BLUR_IMG_SIZE + ), + 1 ) } else { - blurWidth = Math.round( - (imageSize.width / imageSize.height) * BLUR_IMG_SIZE + blurWidth = Math.max( + Math.round( + (imageSize.width / imageSize.height) * BLUR_IMG_SIZE + ), + 1 ) blurHeight = BLUR_IMG_SIZE } From 14016e95b14cc70fe487e07560a1d1ba66f6124d Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 16 Sep 2022 14:47:56 -0400 Subject: [PATCH 2/3] Add test --- .../image-future/default/pages/static-img.js | 18 ++++++++++++++++++ .../default/public/super-wide.png | Bin 0 -> 446 bytes 2 files changed, 18 insertions(+) create mode 100644 test/integration/image-future/default/public/super-wide.png diff --git a/test/integration/image-future/default/pages/static-img.js b/test/integration/image-future/default/pages/static-img.js index 26c2e5a55fbc575..f4c4552f2d7db5b 100644 --- a/test/integration/image-future/default/pages/static-img.js +++ b/test/integration/image-future/default/pages/static-img.js @@ -11,6 +11,8 @@ import testGIF from '../public/test.gif' import testBMP from '../public/test.bmp' import testICO from '../public/test.ico' import widePNG from '../public/wide.png' +import tallPNG from '../components/tall.png' +import superWidePNG from '../public/super-wide.png' import TallImage from '../components/TallImage' @@ -40,6 +42,22 @@ const Page = () => { + + + +
diff --git a/test/integration/image-future/default/public/super-wide.png b/test/integration/image-future/default/public/super-wide.png new file mode 100644 index 0000000000000000000000000000000000000000..8bae369b47c0c5ba14a9853a16e980ebb604b942 GIT binary patch literal 446 zcmeAS@N?(olHy`uVBq!ia0y~yU~d4jB{|rDgnPbQZeW4O-J4X1_B2* ztYhf2zukLe$*PIH3jb}4KkEUF2Z43l{n;Tbh7bJA5)h`sAqJ4sfuO^nff2$|;z@uo c8aRfmGP^k|8KWb literal 0 HcmV?d00001 From 7072a49efacf0907d462c47f3d3f7066ce1ae344 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 16 Sep 2022 15:55:19 -0400 Subject: [PATCH 3/3] Fix lint --- packages/next/build/webpack/loaders/next-image-loader.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-image-loader.js b/packages/next/build/webpack/loaders/next-image-loader.js index 0f264c2dc93d061..a336090874db9a9 100644 --- a/packages/next/build/webpack/loaders/next-image-loader.js +++ b/packages/next/build/webpack/loaders/next-image-loader.js @@ -36,16 +36,12 @@ function nextImageLoader(content) { if (imageSize.width >= imageSize.height) { blurWidth = BLUR_IMG_SIZE blurHeight = Math.max( - Math.round( - (imageSize.height / imageSize.width) * BLUR_IMG_SIZE - ), + Math.round((imageSize.height / imageSize.width) * BLUR_IMG_SIZE), 1 ) } else { blurWidth = Math.max( - Math.round( - (imageSize.width / imageSize.height) * BLUR_IMG_SIZE - ), + Math.round((imageSize.width / imageSize.height) * BLUR_IMG_SIZE), 1 ) blurHeight = BLUR_IMG_SIZE