Adding custom emoji/emoticons via a plugin


(Robin Ward) #1

One thing a few people have asked for is the ability to add custom emoji. While we haven’t gotten around to making a nice UI for people to do it, those comfortable creating plugins can now tap into the emojis and add them easily.

Use the latest version of Discourse, then you just have to create a plugin that executes the following method to register a new emoji:

Discourse.Dialect.registerEmoji('trout', '');

Here’s a sample plugin that adds a :trout: emoji with the correct plugin.rb and setup:

(Mittineague) #2

I see the URL is to your CDN. So this will pull images from offsite rather than having them as precompiled assets?

(Robin Ward) #3

Yes, to keep this plugin example simple I just used a URL to an asset I knew was already there.

(Mittineague) #4

Thanks, this will make a lot of people very happy.

Personally, I’ve grown to like some of the emojis and there sure are a lot of them. But I know many have issues with them.

(Sam Saffron) #5

Will it override an existing emoji?

(Robin Ward) #6

No, it uses a different lookup list. But it could!

(Sam Saffron) #7

Yeah, if it does we can very easily ship a “Google/Apple” style emoji plugin :smile:


Neat! Just an hour or two before you posted this… I spent a couple hours modifying the emoji plugin to include some custom emoticons… including a trout slap!


Judging by my notification of this post, emojis don’t seem to work in emails. Not sure if intentional.

(Sam Saffron) #10

Intentional on short emails otherwise spam assassin gets angry

(Robin Ward) #11

Okay great advice @sam I made a change so that emoji in plugins will overwrite any emoji with the same name. So people can make a plugin for a totally different emoji set if they prefer!

(I also made sure new emoji were showing in the autocomplete search):

(Kane York) #12

We could ship it by default if we got some kind of plugin disabling :wink:

Or make it a site setting?

(Sam Saffron) #13

we do want to improve our emoji support and pretty much have something more similar to what slack has out-of-the-box.

(Mittineague) #14

Any timeline as to when registerEmoji will make it into Dialect?

(Robin Ward) #15

It’s in tests-passed now. We are very close to releasing 1.1 (today perhaps?) it’ll be in there.

(cpradio) #16

Are you running against master or only Stable?

(Mittineague) #17

My localhost Dashboard doesn’t show the version info (no sidekiq running) but I’ve been using this in the CLI
git reset --hard origin/master

(Robin Ward) #18

Master should have Discourse.Dialect.registerEmoji available, there is likely something wrong with your setup.

(cpradio) #19

Are you following that with a git pull origin master call? As that will reset your pointer and remove any changed files you have (unless you stash them), but it won’t necessarily pull down the latest code (or so I think).

(Mittineague) #21

Well, no missed typos. It seems the problem once again has to do with my inability to find a way to get symlinks to work on my localhost Windows 7 Home Premium OS.

I’ve found a few registy hack solutions from searching, but I’m not one to do that based on some random search result. And I’m hesitant to modify the Registry even when a MicroSoft solution.

But I’ll keep looking.