A user, zebateira, reported an issue where images were not showing up in topics created from embedded comments on blog.ipfs.io due to relative image URLs not being parsed correctly. Simon investigated and found that Discourse was not adding a slash after the host name when absolutizing the src URL, resulting in broken images.
The issue was tracked to a specific line of code in topic_embed.rb (#4). Simon suggested a change to add a slash after the uri.host if the src starts with a relative path, but noted that it would take some time to implement.
After several follow-ups from zebateira and zebateira, Simon mentioned that the issue was being discussed internally as part of broader improvements to embedding.
Ultimately, nbianca, the assigned engineer, pushed a patch to resolve the issue, and the correct image now shows up in the affected topic.
On our paid hosted instance discuss.ipfs.io, topics created from the embedded comments in the site blog.ipfs.io are not correctly importing the urls of images in the post, making the images not show up in the topic content (after you click “Show full post…”).
It seems that relative image urls are not being parsed correctly and are missing a slash in the final discourse topic content?
The urls are https://blog.ipfs.io..assets/ where they should be https://blog.ipfs.io/../assets/
This results in a broken image. Editing the src my browser’s console to https://blog.ipfs.io/../assets/img/2021-04-14-cardheader-scaling-ethereum-1459531d.1459531d.png fixes the issue.
I’m not sure how Discourse should be handling this. I’ll have a closer look at the code that’s used to absolutize the src URL on Discourse and see if there’s anything that can be done.
The cause of the issue is that the images on your website are being served with a relative path (../). Discourse is correctly adding the host name to the path, but it is failing to add a slash (/) after the host.
The issue seems to be happening here:
I can’t think of any cases where it wouldn’t make sense to add a slash after the uri.host if the src starts with a relative path. I’ll ask our engineering team to see what they think about making that change. It’s likely that we won’t be able to get back to you about this before early next week.
Sorry, no updates on this yet. The issue has been noted by our engineering team. I’ll keep following up on it to make sure that it gets fixed. Unfortunately I cannot think of any workarounds for the issue on your site.
Sorry, there’s no ETA on this yet. We are having an internal discussion about improvements that need to be made to embedding. The issue of the embed code not handling relative src paths has been noted and will be fixed.