Can emoji be rendered with absolute URLs?


(Joe Boutros) #1

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:">


(Simon Cossar) #2

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


(Sam Saffron) #3

: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?


(Sam Saffron) #4

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


(Régis Hanol) #5

This should fix it :banana:

NOTE: requires a rebake for existing posts


(Joe Boutros) #6

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>


(Jeff Atwood) #7