From 00c7a01524e33c9a96c960b68ef18fc561b24706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Fri, 19 Jan 2018 19:14:19 +0100 Subject: [PATCH] Fix images disappearing from rendered markdown files Fixes #3608 --- packages/gatsby-remark-images/src/index.js | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/gatsby-remark-images/src/index.js b/packages/gatsby-remark-images/src/index.js index 2384553001b01..af68e330876b6 100644 --- a/packages/gatsby-remark-images/src/index.js +++ b/packages/gatsby-remark-images/src/index.js @@ -85,19 +85,19 @@ module.exports = ( class="gatsby-resp-image-wrapper" style="position: relative; display: block; ${ options.wrapperStyle - }; max-width: ${presentationWidth}px; margin-left: auto; margin-right: auto;" + }; max-width: ${presentationWidth}px; margin-left: auto; margin-right: auto;" > ${node.alt ? node.alt : defaultAlt} @@ -197,11 +199,14 @@ module.exports = ( formattedImgTag, resolve ) - // Replace the image string - thisImg.replaceWith(rawHTML) - } else { - return resolve() + + if (rawHTML != null) { + // Replace the image string + thisImg.replaceWith(rawHTML) + } } + + return resolve() } // Replace the image node with an inline HTML node. @@ -213,6 +218,6 @@ module.exports = ( ) ).then(htmlImageNodes => markdownImageNodes.concat(htmlImageNodes).filter(node => !!node) + ) ) - ) }