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 1/2] 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) + ) ) - ) } From c332a76124ae17b71224681940af37bca24e53c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Fri, 19 Jan 2018 19:23:19 +0100 Subject: [PATCH 2/2] Revert invalid indentation changes --- packages/gatsby-remark-images/src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-remark-images/src/index.js b/packages/gatsby-remark-images/src/index.js index af68e330876b6..3dfe2dceee606 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} markdownImageNodes.concat(htmlImageNodes).filter(node => !!node) - ) ) + ) }