TylerBarnes / gatsby-wordpress-inline-images

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

Add more detailed explanations to Readme #18

Closed sylflo closed 4 years ago

sylflo commented 4 years ago

I seriously must have missed something but I am not sure about a few things

I update gatsby-node.js like this

 resolve: "gatsby-source-wordpress",
      options: {
        baseUrl: "your-site.com",
        protocol: "http",
        maxWidth: 650,
        wrapperStyle: ``,
        postTypes: ["post", "page"],
        backgroundColor: `white`,
        withWebp: false,
        plugins: [
          {
            resolve: `gatsby-wordpress-inline-images`,
            options: {
              baseUrl: `your-site.com`,
              protocol: `http`
            },
          },
        ],

I make a grapql request so I went to the GraphiQL console and send this

{
  allWordpressPost {
    edges {
      node {
        id
        content
      }
    }
  }
}

So far so good, now I have a base64 in the content property. My question am I supposed to parse this base64 or is there a cleaner way to get the images ? Maybe using imageSharp

TylerBarnes commented 4 years ago

The images will be mixed into the HTML of your post content so this plugin should just work when you install it. If you parse the content into React you should be good! You can use dangerouslySetInnerHtml or this https://www.npmjs.com/package/react-html-parser

sylflo commented 4 years ago

Ah ok, I was being naive and stupid, I thought the plugin will send a list of images but it does make more sense to do what it actually does

TylerBarnes commented 4 years ago

No worries! It's an honest and not-stupid mistake. This is definitely the kind of issue I'd open myself 🤣 Let me know if you need any more help!