Can emoji be rendered with absolute URLs?

We’re using the API to get topic and post content and display it on a different site. Emoji are being rendered as images with relative links, which are obviously not loading from the other site.

I read through a topic about the wordpress plugin where it seems like a change was made to make emoji URLs absolute.

Do we need to set some sort of base URL in the settings?

<img src="/images/emoji/emoji_one/slight_smile.png?v=2" title=":slight_smile:" class="emoji" alt=":slight_smile:">

3 Likes

This is a problem for the wp-discourse plugin as well. The wp-discourse plugin attempts to fix relative urls with a regular expression, but that has a few problems.

I think the relevant code is here. I’d send a PR, but I don’t know how to properly get a forum’s absolute url from the front end.

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/emoji.js.es6#L60

2 Likes

:frowning2: yeah frowning2 should definitely be a fully qualified URL in cooked as are all the rest of the images. Also it is a bug it is not using the CDN.

@zogstrip maybe have a look at this, recently you played around in this area?

3 Likes

Recategorizing this a bug, albeit minor. We should be using CDN for our emojis in cooked.

This should fix it :banana:

https://github.com/discourse/discourse/commit/caa1aea995be62236af2421bc61b2e85455a22b3

NOTE: requires a rebake for existing posts

2 Likes

Interestingly, we seem to get absolute URLs on our dev instance:

<div class="cooked"><p>This is kinda crazy <img src="https://cdn-standard.discourse.org/images/emoji/emoji_one/slight_smile.png?v=2" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p></div>