Skip to content

Commit

Permalink
Fix gatsby-remark-image (#3620)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews authored Jan 20, 2018
1 parent cc468b0 commit bd7a4b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions packages/gatsby-remark-images/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,5 @@ test(`it leaves non-relative HTML img tags alone`, async () => {
`.trim()

const nodes = await plugin(createPluginOptions(content, imagePath))

expect(nodes.length).toBe(0)
expect(nodes[0].value).toBe(content)
})
16 changes: 9 additions & 7 deletions packages/gatsby-remark-images/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = (
}
return null
})

if (!imageNode || !imageNode.absolutePath) {
return resolve()
}
Expand Down Expand Up @@ -142,15 +143,16 @@ module.exports = (
) {
const rawHTML = await generateImagesAndUpdateNode(node, resolve)

if (rawHTML != null) {
if (rawHTML) {
// Replace the image node with an inline HTML node.
node.type = `html`
node.value = rawHTML
}
return resolve(node)
} else {
// Image isn't relative so there's nothing for us to do.
return resolve()
}

// Image isn't relative so there's nothing for us to do.
return resolve()
})
)
).then(markdownImageNodes =>
Expand Down Expand Up @@ -200,13 +202,13 @@ module.exports = (
resolve
)

if (rawHTML != null) {
if (rawHTML) {
// Replace the image string
thisImg.replaceWith(rawHTML)
} else {
return resolve()
}
}

return resolve()
}

// Replace the image node with an inline HTML node.
Expand Down

0 comments on commit bd7a4b0

Please sign in to comment.