Best way to add custom emoji codes?

Hi there, I’m trying to figure out the best way to clean up a bunch of emoji codes from my Drupal forum import (many of which were created when they were still known as “smiley” sets and “emoji” wasn’t even in our vocabulary yet).

I could do it in the import script (haven’t done a final production migration yet), but that would require adding about 20 additional gsub() calls to the already complex and slowish preprocess_posts() function of the importer.

I was planning on a simple find/replace with rake posts:remap after the final import, but each of the 20 replacements will take about an hour to run and also the remap function appears to be quite broken.

I looked into the Admin > Customize > Emoji interface, but it won’t let me use emoji codes like :THUMBS-UP: with a dash, it turns dashes into underscores.

Any other better options? Thanks!

2 Likes

I just discovered the /admin/customize/watched_words/action/replace interface, which appears to work for this. Also allows uploading a number of replacements from a .csv file.

The downside is that it requires a rake posts:rebake to make the replacements appear in prior posts, which in my case takes over 24 hours to run. The main purpose of the Watched Words feature appears to be for censoring or otherwise acting on words (or emojis) that appear in new posts, whereas in my case the problem is mainly with old posts where the old forum engine automatically inserted its unique codes when the user added an emoji to a post.