Images not showing when topic is created from embedded comments on site site

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…”).

Example:

Blog post: Welcome to IPFS Weekly 133 | IPFS Blog & News
Discourse Topic: Welcome to IPFS Weekly 133 | IPFS Blog & News - Blog Posts - discuss.ipfs.io

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/

Thank you!

1 Like

The issue is related to how the image src is being set on your website. Looking at the post at Welcome to IPFS Weekly 133 | IPFS Blog & News, the image in the post has its src set to

../assets/img/2021-04-14-cardheader-scaling-ethereum-1459531d.1459531d.png

That causes Discourse to set the src to

https://blog.ipfs.io../assets/img/2021-04-14-cardheader-scaling-ethereum-1459531d.1459531d.png

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.

1 Like

Thank you Simon, appreciate you looking into it.

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:

https://github.com/discourse/discourse/blob/master/app/models/topic_embed.rb#L161-L170

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.

3 Likes

thank you simon, that’s ok, next week is fine. have a nice weekend!

Hello @simon!

Any updates on this?

Thank you!

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.

1 Like

Hey Simon, hope all is well.

Any ETA on this?

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.

2 Likes

Hello,

I am the engineer assigned to this issue. I just pushed a patch to your site and the problem was resolved. The correct image shows up in Welcome to IPFS Weekly 133 | IPFS Blog & News - Blog Posts - discuss.ipfs.io.

Please let me know if there is anything else I can help you with.

5 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.