diff --git a/util/resizeImage.js b/util/resizeImage.js index fe8c923..5eaf13b 100644 --- a/util/resizeImage.js +++ b/util/resizeImage.js @@ -29,18 +29,14 @@ function resizeImage( const resizeOptions = { fit: fit }; - if (width) { - width = parseInt(width, 10); - if (width > 0) { - resizeOptions.width = width; - } + const parsedWidth = width ? parseInt(width, 10) : 0; + if (parsedWidth > 0) { + resizeOptions.width = parsedWidth; } - if (height) { - height = parseInt(height, 10); - if (height > 0) { - resizeOptions.height = height; - } + const parsedHeight = height ? parseInt(height, 10) : 0; + if (parsedHeight > 0) { + resizeOptions.height = parsedHeight; } const sharp = SHARP(body).withMetadata().resize(resizeOptions);