Inline Images in Gatsby Wordpress source plugin

973 views Asked by At

I'm using this plugin https://www.gatsbyjs.com/plugins/@draftbox-co/gatsby-wordpress-inline-images/ following all instructions, but does not work.

Does anyone know what could be going wrong?

gatsby-config.js:

{
      resolve: 'gatsby-source-wordpress',
      options: {
        excludedRoutes: [
          '/wp/v2/users/**',
          '/wp/v2/settings*',
          '/wp/v2/themes*'
        ],
        baseUrl: 'domain',
        protocol: 'http',
        postTypes: ["post", "page"],
        plugins: [
          {
            resolve: `@draftbox-co/gatsby-wordpress-inline-images`,
            options: {
              baseUrl: `domain`,
              protocol: `http`
            }
          }
        ],
        hostingWPCOM: false,
        useACF: true,

        searchAndReplaceContentUrls: {
          sourceUrl: 'http://domain',
          replacementUrl: ''
        }

        
      }
    },

My Gatsby Blog

3

There are 3 answers

0
Ricardo de Paula On BEST ANSWER

I could access the wordpress site both http and https. I just change protocol url (gatsby plugin config) to https and works

      resolve: 'gatsby-source-wordpress',
      options: {
        excludedRoutes: [
          '/wp/v2/users/**',
          '/wp/v2/settings*',
          '/wp/v2/themes*'
        ],
        baseUrl: 'domain.net',
        protocol: 'https',
        postTypes: ["post", "page"],
        
        plugins: [
          {
            resolve: '@draftbox-co/gatsby-wordpress-inline-images',
            options: {
              baseUrl: 'domain.net',
              protocol: 'https',
              withWebp: true,
            }
          }
        ],
        hostingWPCOM: false,
        useACF: true,

        searchAndReplaceContentUrls: {
          sourceUrl: 'https://domain',
          replacementUrl: ''
        }

        
      }

5
RustyJames On

Gatsby is buggy sometimes when updating images and hrefs.

Try to clear cache.

gatsby clean

before

gatsby develop
0
Jurrian On

The reason you don't see inline images is because of your config:

 searchAndReplaceContentUrls: {
   sourceUrl: 'http://domain',
   replacementUrl: ''
}

If you remove it, you'll see inline images with the correct Wordpress src url. The downside is that your links (if you're using gatsby-link) won't be pre-fetched because they will have the Wordpress sourceUrl in the url.