TylerBarnes / gatsby-wordpress-inline-images

Fluid images for gatsby-source-wordpress inline images in post_content
57 stars 25 forks source link

TypeError: Cannot read property replace of undefined #2

Closed Abdulhakimsg closed 5 years ago

Abdulhakimsg commented 5 years ago

Hi, i have receiving this problem for days.I really need to solve this quick.Help?

error Plugin gatsby-wordpress-inline-images returned an error

  TypeError: Cannot read property 'replace' of undefined

  - removeImageSizes.js:4 removeImageSizes
    [gatsby]/[gatsby-wordpress-inline-images]/utils/removeImageSizes.js:4:40

  - gatsby-node.js:109 replaceImage
    [gatsby]/[gatsby-wordpress-inline-images]/gatsby-node.js:109:15

  - gatsby-node.js:82 Promise.all.imageRefs.map.thisImg
    [gatsby]/[gatsby-wordpress-inline-images]/gatsby-node.js:82:7

  - Array.map

  - gatsby-node.js:81 transformInlineImagestoStaticImages
    [gatsby]/[gatsby-wordpress-inline-images]/gatsby-node.js:81:15

  - gatsby-node.js:45 Promise.all.entities.map
    [gatsby]/[gatsby-wordpress-inline-images]/gatsby-node.js:45:7

  - Array.map

  - gatsby-node.js:44 Object.exports.sourceNodes
    [gatsby]/[gatsby-wordpress-inline-images]/gatsby-node.js:44:14

  - api-runner-node.js:214 runAPI
    [gatsby]/[gatsby]/dist/utils/api-runner-node.js:214:37

  - api-runner-node.js:352 resolve
    [gatsby]/[gatsby]/dist/utils/api-runner-node.js:352:19

  - debuggability.js:313 Promise._execute
    [gatsby]/[bluebird]/js/release/debuggability.js:313:9

  - promise.js:483 Promise._resolveFromExecutor
    [gatsby]/[bluebird]/js/release/promise.js:483:18

  - promise.js:79 new Promise
    [gatsby]/[bluebird]/js/release/promise.js:79:10

  - api-runner-node.js:351 Promise.mapSeries.plugin
    [gatsby]/[gatsby]/dist/utils/api-runner-node.js:351:16

  - util.js:16 tryCatcher
    [gatsby]/[bluebird]/js/release/util.js:16:23

  - reduce.js:155 Object.gotValue
    [gatsby]/[bluebird]/js/release/reduce.js:155:18

this is my gatsby-config

{
      resolve: "gatsby-source-wordpress",
      options: {
        baseUrl: "cms.antenn.ai",
        protocol: "https",
        plugins: [
          {
            resolve: `gatsby-wordpress-inline-images`,
            options: {
              baseUrl: `antenn.ai`,
              protocol: `https`,
            }
          }
        ],
        hostingWPCOM: false,
        useACF: true,
        verboseOutput: true,
        maxWidth: 650,
        wrapperStyle: ``,
        backgroundColor: `white`,
      },
    },
TylerBarnes commented 5 years ago

Honestly I'm not sure at first glance. I do see that your baseUrls are different between gatsby-source-wordpress and gatsby-wordpress-inline-images. I think they should be the same (unless you did that for some specific reason). Most likely I need to add an additional check wherever the error is happening. If you can provide a demo repo or invite me to your private repo I can debug.

cseebach-tpc commented 5 years ago

@Abdulhakimsg judging by the differing content of https://cms.antenn.ai/wp-json and https://antenn.ai/wp-json I think @TylerBarnes is correct, the configuration should use cms.antenn.ai as the baseUrl for both sets of options. The CMS url points to the Wordpress instance and the other one is something else, looks like.

cseebach-tpc commented 5 years ago

@TylerBarnes after #3 merges, I can take a whack at putting a more helpful error message PR together that could help folks who run into this problem, like I did when I accidentally supplied a non-functional Wordpress base url

TylerBarnes commented 5 years ago

This looks like it's because the baseUrl options don't match and #3 is merged so I'm closing this. Open a new issue if you're still having issues @Abdulhakimsg