diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-10-07 02:38:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-07 02:38:52 +0200 |
commit | 45682f876d4257c61b1d42469d04dd53fc4f8189 (patch) | |
tree | 38acd9df3c58d3ab0fdd8acd44065bc5b914be40 /app/javascript/mastodon/features/emoji/emoji.js | |
parent | 4413d81d7f7b290f7e69ce3397ca969ea1c96622 (diff) |
Make auto-play GIFs preference affect custom emojis in web UI (#5254)
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({ |