Skip to content

Commit e8c3ff3

Browse files
committed
incorporate review comments
1 parent 2cfff49 commit e8c3ff3

File tree

1 file changed

+7
-5
lines changed
  • packages/gatsby-plugin-sharp/src

1 file changed

+7
-5
lines changed

packages/gatsby-plugin-sharp/src/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ function calculateImageDimensionsAndAspectRatio(file, options) {
8484

8585
function prepareQueue({ file, args }) {
8686
const { pathPrefix, duotone, ...rest } = args
87-
const options = Object.assign(rest, duotone)
88-
const argsDigestShort = createArgsDigest(options)
89-
const imgSrc = `/${file.name}.${options.toFormat}`
87+
// Duotone is a nested object inside transformOptions and has a [Object: Null Prototype]
88+
// So it's flattened into a new object so that createArgsDigest also takes duotone into account
89+
const digestArgs = Object.assign(rest, duotone)
90+
const argsDigestShort = createArgsDigest(digestArgs)
91+
const imgSrc = `/${file.name}.${args.toFormat}`
9092
const outputDir = path.join(
9193
process.cwd(),
9294
`public`,
@@ -100,11 +102,11 @@ function prepareQueue({ file, args }) {
100102

101103
const { width, height, aspectRatio } = calculateImageDimensionsAndAspectRatio(
102104
file,
103-
options
105+
args
104106
)
105107

106108
// encode the file name for URL
107-
const encodedImgSrc = `/${encodeURIComponent(file.name)}.${options.toFormat}`
109+
const encodedImgSrc = `/${encodeURIComponent(file.name)}.${args.toFormat}`
108110

109111
// Prefix the image src.
110112
const digestDirPrefix = `${file.internal.contentDigest}/${argsDigestShort}`

0 commit comments

Comments
 (0)