question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline images in Markdown not being transformed by gatsby-remark-images

See original GitHub issue

Description

I’m trying to use gatsby-remark-images to optimize images in my blog posts, but when I view my blog post, it appears to just load the large image. There is no blur-up effect happening.

Steps to reproduce

Here’s the repo where I can’t make this work.

  1. Place a high-res image in /static/assets
  2. Add an entry in gatsby-config.js so gatsby-source-filesystem can process those images
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `static/assets`,
        path: `${__dirname}/static/assets`,
      },
    },
  1. Add gatsby-remark-images to the gatsby-transformer-remark configuration
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 813,
            },
          },
          {
            resolve: `gatsby-remark-prismjs`,
            options: {
              noInlineHighlight: true,
            },
          },
        ],
      },
    },
  1. Add a reference to my high-res image in a blog post
![](/assets/construction.jpg)

Expected result

When I view my blog post, the blur-up effect should occur before my high-res image is displayed.

Actual result

There is no blur-up effect. The page appears to load the high-res image the same as it would without the plugin.

Environment

  System:
    OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.12.3 - /usr/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 2.7.17 - /usr/bin/python
  Browsers:
    Chrome: 70.0.3538.77
    Firefox: 71.0
  npmPackages:
    gatsby: ^2.18.12 => 2.18.12
    gatsby-background-image: ^0.9.12 => 0.9.12
    gatsby-image: ^2.2.34 => 2.2.34
    gatsby-plugin-linaria: ^2.0.0 => 2.0.0
    gatsby-plugin-manifest: ^2.2.31 => 2.2.31
    gatsby-plugin-netlify-cms: ^4.1.33 => 4.1.33
    gatsby-plugin-offline: ^3.0.27 => 3.0.27
    gatsby-plugin-react-helmet-async: ^1.0.13 => 1.0.13
    gatsby-plugin-sharp: ^2.3.5 => 2.3.5
    gatsby-plugin-typescript: ^2.1.23 => 2.1.23
    gatsby-remark-images: ^3.1.39 => 3.1.39
    gatsby-remark-prismjs: ^3.3.28 => 3.3.28
    gatsby-source-filesystem: ^2.1.40 => 2.1.40
    gatsby-transformer-remark: ^2.6.45 => 2.6.45
    gatsby-transformer-sharp: ^2.3.7 => 2.3.7
  npmGlobalPackages:
    gatsby-cli: 2.7.7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
tmrpcommented, May 27, 2020

@ttstauss I came across these issues as well while working on a recent Gatsby TypeScript project. I fixed the issue by using the gatsby-plugin-netlify-cms-paths plugin. Now, I don’t need to add ../ to the image URLs to get them to work, and the images show now up automatically.

My gatsby-config.js

module.exports = {
  plugins: [
    `gatsby-plugin-typescript`,
    `gatsby-plugin-react-helmet`,
    `gatsby-image`,
    `gatsby-transformer-remark`,
    `gatsby-transformer-yaml`,
    `gatsby-plugin-theme-ui`,
    `gatsby-plugin-emotion`,
    {
     resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/content/img`,
        name: 'image-uploads',
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/content/blog-posts`,
        name: 'blog-posts',
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/content`,
        name: 'content',
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-plugin-netlify-cms-paths`,
            options: {
              // Path to your Netlify CMS config file
              cmsConfig: `/static/admin/config.yml`,
            },
          },
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 2400,
              quality: 100,
              withWebp: true,
              loading: 'lazy',
              linkImagesToOriginal: false,
            },
          },
        ],
      },
    },
    `gatsby-plugin-netlify-cache`,
    {
      resolve: `gatsby-plugin-netlify-cms`,
      options: {
        modulePath: `${__dirname}/src/cms/cms.js`,
      },
    },
    `gatsby-plugin-netlify`,
  ],
}

My NetlifyCMS admin content folders in static/admin/config.yml

media_folder: content/img
public_folder: /img

Hope this helps!

5reactions
sslotskycommented, Jan 5, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Images in Markdown & MDX - Gatsby
Inline images with gatsby-remark-images ... One way to do this is to grab the image filename from a frontmatter field and then transform...
Read more >
Gatsby Remark Images not working for inline images
Came across this issue today with gatsby v4. My problem was that the gatsby-remark-images do not make any changes to some image files....
Read more >
Gatsby.JS: Working with Images in Markdown Posts and Pages
One way to do this is to grab the image filename from a frontmatter field and then transform it with gatsby-plugin-sharp in a...
Read more >
gatsby-remark-images | Yarn - Package Manager
Processes images in markdown so they can be used in the production build. In the processing, it makes images responsive by: Adding an...
Read more >
qupaya meets Gatsby!
Inline images. Since we want standard Markdown, gatsby-transformer-remark is used in conjunction with gatsby-remark-images to process images ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found