From 82fc91293ffa826d83f4deac8874f03ae2c51bbd Mon Sep 17 00:00:00 2001 From: Alexandre Kirszenberg Date: Tue, 21 Aug 2018 17:33:59 +0200 Subject: [PATCH] Remove default values for width and maxWidth, correctly round when width is absent --- packages/gatsby-plugin-sharp/src/index.js | 15 ++++++++------- .../src/extend-node-type.js | 2 -- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index 8237bc0abe00d..0b3d080cd568f 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -127,13 +127,14 @@ const processFile = (file, jobs, cb, reporter) => { } else { clonedPipeline = pipeline } - // Sharp only allows ints as height/width. Since height isn't always - // set, check first before trying to round it. - let roundedHeight = args.height - if (roundedHeight) { - roundedHeight = Math.round(roundedHeight) - } - const roundedWidth = Math.round(args.width) + // Sharp only allows ints as height/width. Since either height or width + // could not be set, check first before trying to round them. + let roundedHeight = args.hasOwnProperty(args, `height`) + ? Math.round(args.height) + : undefined + const roundedWidth = args.hasOwnProperty(args, `width`) + ? Math.round(args.width) + : undefined clonedPipeline .resize(roundedWidth, roundedHeight) .crop(args.cropFocus) diff --git a/packages/gatsby-transformer-sharp/src/extend-node-type.js b/packages/gatsby-transformer-sharp/src/extend-node-type.js index f8a8159b9ac0f..f8d2af200a89c 100644 --- a/packages/gatsby-transformer-sharp/src/extend-node-type.js +++ b/packages/gatsby-transformer-sharp/src/extend-node-type.js @@ -105,7 +105,6 @@ const fixedNodeType = ({ args: { width: { type: GraphQLInt, - defaultValue: 400, }, height: { type: GraphQLInt, @@ -222,7 +221,6 @@ const fluidNodeType = ({ args: { maxWidth: { type: GraphQLInt, - defaultValue: 800, }, maxHeight: { type: GraphQLInt,