Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Output post content is wrapped by gatsby image #31

Open
garethgd opened this issue Apr 3, 2020 · 4 comments
Open

Output post content is wrapped by gatsby image #31

garethgd opened this issue Apr 3, 2020 · 4 comments

Comments

@garethgd
Copy link

garethgd commented Apr 3, 2020

Hi,

I really enjoy the effort that's been put into this plugin. I am just experiencing one small issue. When my inline images have been generated. For some of my posts, all of the content (h1, h2, p, span etc) is wrapped with the gatsby image wrapper (rather than just the images themselves).

<div class=" gatsby-image-wrapper" style="position:relative;overflow:hidden;max-width:100%" data-reactroot=""> My Post content </div>

This skews all my inline images and the images cover my post content. Is there perhaps a property I'm missing in the plugin configuration?

My config:

      {
         resolve: `gatsby-wordpress-inline-images`,
         options: {
           baseUrl: `www.fortniterandomizer.com`,
           protocol: `https`,
           useACF: true,
           wrapperStyle: ``,
           postTypes: ["post", "page"],
         }
       }
     ]
@Jehu
Copy link

Jehu commented May 1, 2020

Same Problem here.
In our case it is a Custom AcfBlock with an image in it. All following blocks are rendered inside the gatsby-image-wrapper

Edit: oh we use gatsby-wordpress-experimental-inline-images by the way.

@garethgd
Copy link
Author

garethgd commented May 2, 2020

Hi @Jehu,

This is far from a permanent solution but it works for me for building my articles at the moment.

I narrowed the issue down to a missing closing div for each gatsby-image-wrapper
If you are using dangerouslySetInnerHTML for your post content you can create function to correct the markup:

parsePostContents = (contents) => {
     let replacedContent = contents.replace(/<\/noscript><\/div>/g, '</noscript></div></div>')
     return replacedContent;
  }

You can then use parsePostContents here:

<section
   className="post-content"
   dangerouslySetInnerHTML={{ __html: this.parsePostContents(post.content)}}
/>

AFAIK @TylerBarnes and the Gatsby team are current working on full fledged solution to Wordpress. So hopefully this ties you over for the moment

@Jehu
Copy link

Jehu commented May 2, 2020

@garethgd My colleague has copied the plugin to a local plugin and made some changes on the code. This resolves it for now. He may consider a pull request.
Oh and wrapping the <img> in a <figure> is a must to get the closing tag problem solved.

@TylerBarnes
Copy link
Owner

Hey all, @garethgd is correct, we're currently working on a completely new WP source plugin that uses WPGraphQL and the functionality of this plugin will be built directly into the source plugin. All my attention has been focused there as the plan is to deprecate gatsby-source-wordpress@v3 and our usage of the REST api. There are too many unavoidable issues with using an untyped API. If anyone is interested in maintaining this package let me know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants