Gatsby: How to compress images linked external .md file

Created on 15 Sep 2019  路  8Comments  路  Source: gatsbyjs/gatsby

Summary

I'm currently fetching github issue data with GraphQL, but I get raw image data from github, which size can be super large.
What I want to do is copying those images to my server and compressing those images as I build my project.
Is there any way to solve this problem?

Relevant information

I've already tried some following plugins which seems helpful in this situation.
gatsby-transformer-remark
gatsby-remark-images
gatsby-remark-copy-linked-files

and now a part of my gatsby-config.js file is like this

{
      resolve: `gatsby-transformer-remark`,
      options: {
          plugins: [{
              resolve: `gatsby-remark-images`,
              options: {
                  maxWidth: 590,
              },
          },
          {
              resolve: `gatsby-remark-copy-linked-files`,
              options: {
                  destinationDir: `images`
              }
          }],
      },
}
awaiting author response question or discussion

Most helpful comment

You can always reopen this issue if you want any help related to that.
Happy Hacking :smiley:

All 8 comments

Hey @mo-ro,
Are you fetching the data from the GitHub's API (external data source)?

Hi @pranshuchittora ,
Yeah, you're right.

I don't think you can do that directly. You might need some kind of middleware to perform that task for you.

Hmm...
If I have those .md files and related images at my local, is it possible to optimize them with the plugins I mentioned?

If the Images are locally present then you can always perform those cool image optimizations.

Shall I close this issue?

Sure, thanks a lot!

You can always reopen this issue if you want any help related to that.
Happy Hacking :smiley:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jimfilippou picture jimfilippou  路  3Comments

rossPatton picture rossPatton  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

andykais picture andykais  路  3Comments