I’ve been using the “WP Discourse” plugin for months now, and it has always worked well with articles composed of galleries plus paragraphs.
I published an article on the blog containing only a gallery of about 60 images, but it is not being displayed on Discourse in the linked topic. Instead, it extracted the text from a GDPR plugin first, and then the footer text.
How can I resolve this? Do I need to add some code to the theme’s functions.php file?
Yes that’s correct. For previously published posts, everything worked fine. I see both the gallery and the text after clicking the “Show Full Post” button.
I’ve attached a working example post here, both on WordPress and Discourse.
In this post there are photos as Gallery and some text.
If the post contains only images (inserted as Gallery), Discourse displays either the footer text or the message in the “Moove GDPR Cookie Compilation” plugin popup. If I disable the GDPR plugin, I see the footer.
If I insert an images as “Photo” (Gutenberg Block), Discourse will show the image but not the Gallery.
The difference is that in the case you reported the Wordpress post only has images in it. In this other case the post also has text in it. Would it be possible to add text before the images in the post you’re having an issue with?
Yes, I would suggest publishing the post again with some text and the images and see if that fixes it. If that doesn’t work we can investigate other options.
I just deleted the topic on Discourse and added some text before and after the Gutenberg “Gallery” block, but unfortunately, it didn’t work. The content is clearly visible in the summary, but as soon as I click the button, it’s replaced by the GDPR plugin message.
Here’s the link to the new topic:
What can I do now to investigate and resolve the issue? I alsoi cleared the cache of WordPress (LiteSpeed and Cloudflare).
Looks like you didn’t make a new post on Wordpress. If you re-use the same post on Wordpress the same preview content is going to be cached. Try making a new post on Wordpress with the same photos but with text at the start.
The basic issue is that the way content is pulled from your site is that it uses a gem called Readability which is based on the Mozilla reader view algorithm.
Essentially what is happening here is that the readability algorithm doesn’t play nicely with image-heavy content. The preview feature is intended for posts that are mostly text.
Basically, yes. One way to test is to use the reader view in Firefox with your Wordpress post to see what the readability gem is likely to produce.
I noticed that I can only find “allowed_embed_selectors” in my Discourse settings.
I changed that by inserting CSS classes from my theme. Also, I used some “tricks” in order to increase readability score and it worked!
I added more text, some image alts and a global “wrapper” for posts to add an <article> tag. It’s working very well on Discourse, even if Firefox shows the GDPR panel as the “readable” content.
I have now a question. Can I extend the Discourse lightbox to the WordPress image imported on the topic?
I noticed that WP-Discourse comments use <article> tag, and 1h ago a member inserted a comment, and the parser selected that text as the main content for the post.
I had to edit the plugin file in order to change the tag, but I know that for next update the edits will be lost.
Is it possibile to fix this parsing problem forever?
The way it works is that the HTML preview in the post retains fidelity with the original content. You’d need a custom plugin to do this.
The basic problem is the same. Trying to get a Wordpress post that is almost entirely images to be 1:1 between Wordpress and Discourse is not what the software is designed for. The reason topic embeds (what powers this on the Discourse side) uses the Readability gem is that the assumption is that you’re dealing with content that is read (i.e. text).
It would be possible to have a reliable photo gallery sync between Wordpress and Discourse, however you’d need to design the customisations (Wordpress plugin and Discourse plugin) to work that way.