I draw frog pictures online. Emoji set designed and offered free by Emoji One |
But there is a solution! I found Emoji One, open-source emoji engineered for the web. This is a great project that made adding emoji support to Amphibian.com extremely simple.
First, they provide their JavaScript and CSS files via CDN, so I didn't have to really install anything directly into my web application. Just a few lines of code into my header template...
<script src="//cdn.jsdelivr.net/emojione/1.5.2/lib/js/emojione.min.js"> </script> <link rel="stylesheet" href="//cdn.jsdelivr.net/emojione/1.5.2/assets/css/emojione.min.css" />
Once that was done, I had a few options. They provide functions for converting both Unicode and shorthand (such as :frog:) into pictures. I decided to go with the shorthand version for my site, mainly because it allowed me to more easily write the comics from my desktop browser (Chrome on Windows).
When I write some lines for a frog's speech bubble, I can type
:pizza: + :bowling: @ :clock730: :question:
which is then converted to emoji when the page loads. It's not 100% automatic, though. I had to add a few lines of JavaScript to my site but it was really simple.
// Emojis! (See http://emojione.com/developers) $(function() { $('.bubble, .free-text').each(function() { var origText = $(this).html(); var eText = emojione.shortnameToImage(origText); $(this).html(eText); }); });
The above code relies on jQuery, which I use on my site. As soon as the page is done loading, it finds every element on the page that has a class of bubble or free-text (the classes I use for speech bubbles and floating text areas) and converts the contents to include emoji images. It happens fast enough that I haven't been able to catch the shorthand text in there, but there could theoretically be some flicker. If I was more serious about this I could do the conversion on the server side instead...but this is just for a comic about frogs.
Make sure you read today's emojinal comic so that you can appreciate all the work I had to do for it. I'm not sure if I'll use emojis in the future, but you never know...
Amphibian.com comic for 30 November 2015 |
No comments:
Post a Comment