diff options
Diffstat (limited to 'app/javascript/mastodon/features/emoji/emoji.js')
-rw-r--r-- | app/javascript/mastodon/features/emoji/emoji.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/javascript/mastodon/features/emoji/emoji.js b/app/javascript/mastodon/features/emoji/emoji.js index 998cb0a06..b70fc2b37 100644 --- a/app/javascript/mastodon/features/emoji/emoji.js +++ b/app/javascript/mastodon/features/emoji/emoji.js @@ -5,6 +5,8 @@ const trie = new Trie(Object.keys(unicodeMapping)); const assetHost = process.env.CDN_HOST || ''; +let allowAnimations = false; + const emojify = (str, customEmojis = {}) => { let rtn = ''; for (;;) { @@ -25,7 +27,8 @@ const emojify = (str, customEmojis = {}) => { // now got a replacee as ':shortname:' // if you want additional emoji handler, add statements below which set replacement and return true. if (shortname in customEmojis) { - replacement = `<img draggable="false" class="emojione" alt="${shortname}" title="${shortname}" src="${customEmojis[shortname]}" />`; + const filename = allowAnimations ? customEmojis[shortname].url : customEmojis[shortname].static_url; + replacement = `<img draggable="false" class="emojione" alt="${shortname}" title="${shortname}" src="${filename}" />`; return true; } return false; @@ -48,12 +51,14 @@ const emojify = (str, customEmojis = {}) => { export default emojify; -export const buildCustomEmojis = customEmojis => { +export const buildCustomEmojis = (customEmojis, overrideAllowAnimations = false) => { const emojis = []; + allowAnimations = overrideAllowAnimations; + customEmojis.forEach(emoji => { const shortcode = emoji.get('shortcode'); - const url = emoji.get('static_url'); + const url = allowAnimations ? emoji.get('url') : emoji.get('static_url'); const name = shortcode.replace(':', ''); emojis.push({ |