Skip to content

Commit

Permalink
Fix gatsby-remark-image
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Jan 20, 2018
1 parent cc468b0 commit a6677ba
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 a6677ba

Please sign in to comment.