I’ll be looking into this today. What I’m seeing on my site is that images published from WordPress are displayed correctly until Discourse attempts to download the remote image. When that is done, I’m ending up with markup like you are getting in the post:
![](upload://kw9YUV5qtquQf5xwatRof6S9RmK.jpeg)
I am not sure if this is related to changes in WordPress 5.3.
If you are getting the We detected an API request using a deprecated authentication method warning, that will not be causing the issue you are having with images. WP Discourse versions 1.9.6 and greater should not be causing that warning. All API requests from the plugin are now using header based authentication.
The problem seems to be that when the Discourse upload markdown is wrapped in HTML tags, the markdown isn’t getting parsed. For example, this is what I’m seeing for a WordPress post after the Discourse PullHotlinkedImages Job is run:
<small>Originally published at: https://scossar.com/figure-tags-cause-issues/
</small><br>
<figure class="wp-block-image">![](upload://3hPHOMnM5v5srjlz5QWGmVxY4AL.jpeg)</figure>
Editing the post to remove any html tags that are surrounding the markdown link solves the issue, but a proper solution will need to be found for this.
If the download remote images to local site setting is enabled on Discourse, the image link will break when Discourse downloads the post from WordPress. The problem will happen any time an image tag with a remote URL is wrapped with HTML tags.
The easiest solutions for this issue are to either disable the download remote images to local site setting, or to not publish full post content from WordPress to Discourse.
In the future, the WP Discourse plugin may remove the option to publish full posts. There are multiple issues that can occurr when publishing full post content from WordPress to Discourse. Most of these issues should be able to be solved by publishing excerpts from WordPress to Discourse and then using the Show Full Post button to display the full post on Discourse. Does this sound like something that could work for your case?
Another possible solution would be to customize the template that is used to publish WordPress posts. Images could be extracted from the posts and then published along with a post excerpt. With a custom template, the image HTML could be structured in a way that doesn’t conflict with the Discourse markdown processor.
Thanks Simon, download remote images to local was the easy solution for now. I am discouraged to hear that publish full posts may go away. The way I currently use it is by publishing a post to wordpress, which then gets published to the Articles section on discourse, which is set to Watching First Post for everyone by default. This way everyone gets an email with the full content of the article, and the best part is they can just reply to the email to add a comment, if they have to take that extra step of visiting the site it’s likely most won’t read the article if there’s just a little snippet, especially if it doesn’t have images which is really important for our site. If publish full posts went away I may consider going away from wordpress and only publish the articles directly in discourse which is not ideal for SEO, etc. but I think the engagement is more important.
I’d miss a full publishing too.
I’m not 100% sure of what you’re suggesting here…
How would you extract images? With a regex?
I could imagine a regex that would replace image tags with proper markdown syntax. Is that what you mean and would this work?
I’m going to look into how difficult it would be for the plugin to assemble a basic HTML version of the post content. The last resort approach would be to use DOMDocument methods to parse the content. Comments that are returned by Discourse are parsed with those methods and I haven’t been getting reports of issues with that.
I think that publishing an excerpt and then having users view the full post by clicking the “Show Full Post” button on Discourse is probably the best solution for this, but I’m reluctant to remove the “Publish full post” option from the WP Discourse plugin.
Thank you for the explanation.
I’ll ask my authors to simply publish the article and click “update”, since publishing then updating the article on WP always seems to fix the images on Discourse.
I’d rather have my authors spending 1 more second on each article than seeing the full publish option disappear
If you have the Discourse download remote images to local site setting enabled, doesn’t the image just disappear again within a few minutes of the post being updated? If that’s not the case, I’ll look into why that fixes the issue.
I do have this setting enabled and the images are still correctly displayed on all my latest articles after days and weeks. Example with a 1 month old article in which I encountered the image issue.
Also, I looked at the images URLs Discourse side and the links are those from WP so the images aren’t downloaded to Discourse. Is it because the site and forum share the same domain?
(site: https://monocycle.info, forum: https://forum.monocycle/info)
I have just pushed WP Discourse version 2.0.2 to the WordPress plugin repo. The update should fix the issue with broken images that’s been happening when posts are published to Discourse with the Block editor.
Images, image galleries, as well as Youtube and Vimeo videos are all now being extracted from posts and formatted in a way that Discourse can handle. Let me know if you run into any issues with the update. If there are still WordPress blocks that are not rendering correctly on Discourse, let me know - blocks can now be parsed by name, so it should be possible to resolve any problems.
Next week I’ll add a filter that can be hooked into to parse any blocks that are too obscure to be dealt with by the plugin.
I had old articles with videos URLs in [video] shortcodes and my most recent articles (less than 3 years) used the ARVE video embedder plugin, wich puts the video URL inside a [arve] shortcode.
So I filtered the posts from WP to Discourse with this:
It was working perfectly and the video URLs only were passed to Discouse, so they showed up embedded on Discourse.
But since the WP-Discourse update, the video aren’t showing up on Discourse.
I also tried simply pasting the youtube URL in tinymce, without shortcode (I learned that no shortcode is required for WP to embed a youtube videosomehow… Or maybe it’s because one of my other plugins or my theme? But I think that doesn’t matter), and removing my preg_replace functions, but the video still won’t show up on Discourse.
Here is my text on WP (plain text, not wysiwyg tab):
edit: also, I noticed that when the article is private on WP, it doesn’t sync on Discourse when we edit the article. That’s a bit annoying when we want to do some tests privately.
That is strange. My hope with the change was that it wouldn’t affect posts that are published with the Classic editor. I’ll try to reproduce the issue. Can you share the markup that you see if you open the post in the editor’s Text tab?
Seems that WP is still using another non-native library, maybe from my theme?
I guess the issue is more on my side than yours, still, it was working well before the update…