gatsby-remark-images not working (gatsby v2)

Created on 24 Jul 2018  Â·  20Comments  Â·  Source: gatsbyjs/gatsby

  1. I have read the issue at #6464 to double check the image is relative path
  2. I have put the .jpg file together with the .md file

Screenshot for 1 and 2
the .md file is in the same directory with the image file

  1. I have double check the gatsby-config.js and here is the snippet:
module.exports = {
  siteMetadata: {
    title: 'Ke Han',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-catch-links',
    'gatsby-plugin-sharp',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              // It's important to specify the maxWidth (in pixels) of
              // the content container as this plugin uses this as the
              // base for generating different widths of each image.
              maxWidth: 700,
            },
          },
        ],
      },
    },
  ],
}

  1. I have double check my markdown to ensure it points to the correct file:
    ![Chinese Salty Egg](./fanfan.jpg)

  2. The version of my gatsby-remark-images and gatsby-plugin-sharp are 1.5.67 and 1.6.48 respectively.

  3. I have double checked the documentations on Gatsby V1 and Gatsby V2

After all this, the images are still not showing.
Screenshot 2: the images does not show up in the web page
image

Screenshot 3: gatsby-remark-images is not even doing the work
screenshot 2018-07-24 21 06 45

My environment:

  1. Mac OS 10.11.1
  2. Google Chrome Version 67.0.3396.99 (Official Build) (64-bit)
  3. Using Gatsby V2

I have read the following before I came to this point:
Gatsby Starter Blog V2 Example
Example on how to insert images into markdown

Everything appears normal during compiling:
screenshot 2018-07-24 21 25 38

Please enlighten me on this issue, thanks.

help wanted bug

Most helpful comment

I actually stumbled into this case again, and it seems that only by applying @martin-css solution of adding ignoreFileExtensions: [] I was able to solve this

All 20 comments

The version of my gatsby-remark-images and gatsby-plugin-sharp are 1.5.67 and 1.6.48 respectively

You need to use the v2 versions of the plugins. The migration guide explains that

@LeKoArts thanks for reply.

I have go through every npm packages that I had and update them, now my dependencies are:

  "dependencies": {
    "gatsby": "^2.0.0-beta.56",
    "gatsby-plugin-catch-links": "^1.0.24",
    "gatsby-plugin-react-helmet": "^3.0.0-beta.4",
    "gatsby-plugin-sharp": "^2.0.0-beta.7",
    "gatsby-remark-images": "^2.0.1-beta.9",
    "gatsby-source-filesystem": "^2.0.1-beta.9",
    "gatsby-transformer-remark": "^2.1.1-beta.4",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-helmet": "^5.2.0"
  }

Is there anything I need to take note when using latest packages related to my problem above? Because the problem still persists.

I have double check the config file at branchv2 at gatsby-starter-blog

This is my gatsby-config.js

plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-catch-links',
    'gatsby-plugin-sharp',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              // It's important to specify the maxWidth (in pixels) of
              // the content container as this plugin uses this as the
              // base for generating different widths of each image.
              maxWidth: 700,
            },
          },
        ],
      },
    },
  ],

Is there any place where I can look for regarding the syntax changes for specific plugins at Gatsby?
I have read the following:
Migrating from v1 to v2

Also, is there any additional packages / plugins required for this to work?
Just in case the gatsby-remark-images page didn't get updated.

I can confirm that gastby-remark-images (2.0.1-beta.9) isn't working for me either. I don't have time today to dig into why but gatsby-remark-copy-linked-files does work with ignoreFileExtensions set to [] as a clunky work around in the meantime.

Not sure if it affects my case, but to follow suit I followed gatsby-config.js@v2 to install gatsby-transformer-sharp just that everything is similar with the example.

But, no luck. still not working.

ps: gatsby-transformer-sharp I installed is version ^2.1.1-beta.6, doubled check the migration guide and concluded that none of those relevant to my use case.

Just an update, I tried the canary tag which worked then tried the next tag again and responsive images are now being inserted into the HTML on a production build. Must have been a cache or module version issue.

@khmy2010 Worth noting that you don't see the output in development (e.g. gatsby develop), only the production build (gatsby build). However, would be nice to see something in development other than a broken image link.

Try deleting your node_modules and .cache folder and reinstalling the packages.

Can you provide a sample repo?

Hi @LeKoArts, I have deleted my node_modules and .cache folder and reinstall the package by running npm install

No luck, nothing works.

My repo: https://github.com/khmy2010/kehan.com

Thanks for the detailed report @khmy2010 - there's nothing that looks obviously wrong above. ~Are you able to post a link to your project's source code?~ Edit: I saw you added this since I opened this issue yesterday :)

Or you could try checking out the Gatsby repo and running the using-remark example site?

There's a page there that demos using images: https://using-remark.gatsbyjs.org/responsive-images-and-iframes/

Then work back from there and see if there's any differences in the example project vs your project.

Hi, I have similar issue.

If I get gatsby-starter-blog and install it with the flag #v2, gatsby-remark-images doesn't work. Images are like @khmy2010 described.

I've got the example repo @m-allanson pointed at, the same, doesn't work, but when I deployed it to Netlify it works
demo: https://eager-jang-b3cdb0.netlify.com/responsive-images-and-iframes/ thats
repo: https://github.com/greglobinski/gatsby-test-2

Any idea what's the problem, my localhost is

  • windows 7
  • yarn 1.3.2
  • npm 5.6.0
  • node 8.11.1

When I started with gatsby v1 I had some problems to make sharp work, probably like many Win users. Something changed with regard to it and gatsby v2, any special treatment? :)

ps: gatsby-remark-images on localhost does not do its job, but it also does not send any errors messages.

@khmy2010 Could you please check if deploying resolves your issue too?

I spent a bit of time digging into this and there sure seems to be something odd going on...

It seems like files isnt' being passed in correctly, which is preventing the images from being processed. I haven't yet had a chance to investigate further.

@greglobinski hmm that's interesting that your site works on netlify but not locally.

If anyone has the time to investigate further, there's a new debugging guide that may be useful https://next.gatsbyjs.org/docs/debugging-the-build-process/

I don't know why, but I know that if one of these is higher than versions below, the gatsby-remark-images does not do the job :)

Till these versions images are generated as they should
"gatsby": "2.0.0-beta.56",
"gatsby-transformer-remark": "2.1.1-beta.3",

Update:
Confirm @giraffesyo 's statement, gatsby on beta 59 works fine.

This bug is not related to the gatsby package, as I can operate fine on beta 59. However, as soon as I upgrade from gatsby-transformer-remark beta 3 to beta 4 the bug is there.

as soon as I upgrade from gatsby-transformer-remark beta 3 to beta 4 the bug is there

This might be the relevent commit: https://github.com/gatsbyjs/gatsby/commit/f0ef8b2fe2cfbffc8bffd81c043edf820200bf5a

Fixed in https://github.com/gatsbyjs/gatsby/pull/6792

Thanks @giraffesyo!

I actually stumbled into this case again, and it seems that only by applying @martin-css solution of adding ignoreFileExtensions: [] I was able to solve this

I got the same issue again as well.

I also ran into the same issue.

What is more weird is that 22 out of 69 images are processed. All of these processed images work fine (the src of parsed img in the markdown is correctly set, and the images of different versions are placed in the destination folder), whereas the rest of pictures and their respective imgs in the markdown remain unprocessed. The images that are processed seem determined and not random.

I have also found that in the GraphiQL, querying images with the following GraphQL query will yield all the 69 images, including those that are not processed.

  allImageSharp {
    nodes {
      id

    }
  }

What is more important is once the src of the pictures are queried (for example using the following query), the process of the rest of images will start, and the thumbnails will be created. The markdown will remain unchanged, though.

query MyQuery {
  allImageSharp {
    nodes {
      id
      sizes {
        src
      }
    }
  }
}

QQ截图20190712110804

Currently I have to use the gatsby-remark-copy-linked-files to process the images.

package.json

"gatsby": "~2.13.15",
"gatsby-plugin-sharp": "~2.2.4",
"gatsby-remark-images": "~3.1.4",
"gatsby-transformer-remark": "~2.6.3",
"gatsby-transformer-sharp": "~2.2.2",

My repo: https://github.com/vicblog/VicBlog-Gatsby.

I've just come across this, suffering the same issue. I am running Gatsby 2.18.6 and gatsby-transformer-remark ^2.6.38. I have tried most of the things listed under this issue as well as a few other similar ones stating the same problem, but to no avail. Clearing /node_modules and /.cache did nothing for me either.

However, I tried downgrading gatsby-transformer-remark to 2.1.1-beta.3 as mentioned by @greglobinski. Initially this didn't do anything, but I then found that changing file extensions from .jpg to .jpeg on all affected images seemed to solve the problem - they all appear perfectly now.

This is definitely odd and not a solution I would have expected to have worked but for some reason it does.

tl;dr - gatsby-transformer-remark @ 2.1.1-beta.3 and change the file extension of affected images from .jpg to .jpeg.

Came across this today... after about 30 mins, I just did uninstall and reinstall on ‘gatsby-transformer-remark’ small minor bump on the version and then it just works as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timbrandin picture timbrandin  Â·  3Comments

dustinhorton picture dustinhorton  Â·  3Comments

3CordGuy picture 3CordGuy  Â·  3Comments

Oppenheimer1 picture Oppenheimer1  Â·  3Comments

ghost picture ghost  Â·  3Comments