From 60ae257882f40739b16b4e7eac9a1ea40bd782a1 Mon Sep 17 00:00:00 2001 From: Paul-Louis NECH Date: Mon, 14 Jun 2021 22:08:58 +0200 Subject: [PATCH] feat: Resize, cloudinary --- next.config.js | 9 +++++++-- pages/photos/[id].js | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/next.config.js b/next.config.js index 2b1689f..4e5dc94 100644 --- a/next.config.js +++ b/next.config.js @@ -1,3 +1,8 @@ // next.config.js -const withImages = require('next-images') -module.exports = withImages() +module.exports = { + images: { + domains: [ + 'res.cloudinary.com' + ], + }, +} diff --git a/pages/photos/[id].js b/pages/photos/[id].js index c56af71..4f5fe17 100644 --- a/pages/photos/[id].js +++ b/pages/photos/[id].js @@ -56,9 +56,14 @@ export async function getStaticProps({ params }) { // Fix dimensions if really big picture console.log("Pic dims: ", pic.dimensions.width, pic.dimensions.height); + if (pic.dimensions.widths > 1000 || pic.dimensions.heigth > 1000) { + pic.dimensions.width /= 2; + pic.dimensions.height = 2; + console.log("Resized: ", pic.dimensions.width, pic.dimensions.height); + } if (pic.dimensions.width > 1000 || pic.dimensions.heigth > 1000) { - pic.dimensions.width = pic.dimensions.width / 2; - pic.dimensions.heigth = pic.dimensions.heigth / 2; + pic.dimensions.width /= 2; + pic.dimensions.height /= 2; console.log("Resized: ", pic.dimensions.width, pic.dimensions.height); >>>>>>> 54109d5 (feat: Modulated Links) } -- libgit2 0.27.0