jmadler / emoji-picker

Add a slick emoji selector to input fields and textareas on your website.
Other
1.31k stars 318 forks source link

Add option to replace the unicode equivalent with the image instead #94

Open mrparkerlol opened 6 years ago

mrparkerlol commented 6 years ago

I am working on an application which will use emojis, and so far from what I can tell there is no option to use images instead of the unicode symbols.

The unicode symbols are ugly and I'd very much prefer using the images instead. Is it possible to do this currently or will this have to be added?

Thanks

moslem-hadi commented 6 years ago

+1

deveshgoyal commented 6 years ago
function  unicodeToImage (input) {
      if (!input) {
        return '';
      }
      if (!Config.rx_colons) {
        Config.init_unified();
      }
      return input.replace(Config.rx_codes, function(m) {
        var $img;
        if (m) {
          $img = $.emojiarea.createIcon($.emojiarea.icons[":"+Config.reversemap[m]+":"]);
          return $img;
        } else {
          return '';
        }
      });
    };

usage : unicodeToImage('😍')

output : <img src="/static/chat/website/static/images/emoji/blank.gif" class="img" style="display:inline-block;width:25px;height:25px;background:url('/static/chat/website/static/images/emoji/emoji_spritesheet_0.png') -150px 0px no-repeat;background-size:675px 175px;" alt=":heart_eyes:">