jsila/emoji-images-php
最新稳定版本:0.1.0
Composer 安装命令:
composer require jsila/emoji-images-php
包简介
Parses text for emoji names and converts them to corresponding images.
README 文档
README
Main functionality of the package is parsing text for emoji names (surrounded by double colons) and converting them to corresponding images. It makes use of Twemoji.
Install
Via Composer
$ composer require jsila/emoji-images-php
Usage
$emoji = new JSila\Twemoji\Twemoji; echo $emoji->parseText('Today is :sunny: without a single :cloud:.'); // outputs 'Today is <img src="//twemoji.maxcdn.com/16x16/2600.png" alt="black sun with rays" class=""> without a single <img src="//twemoji.maxcdn.com/16x16/2601.png" alt="cloud" class="">.'
Icons size defaults to 16, but you can override it with 36 or 72. Just pass the appopriate number to constructor.
$emoji = new JSila\Twemoji\Twemoji(36);
Besides parsing the text for emojis you can also get just the url address for specific emoji.
$emoji->getUrl(':sunny:'); // outputs '//twemoji.maxcdn.com/16x16/2600.png'
It can return image of single emoji (not printing it).
$emoji->getImage(':sunny:'); // returns '<img src="//twemoji.maxcdn.com/16x16/2600.png" alt="black sun with rays" class="">'
Both parseText and getImage optionally accept second parameter which represents classes to be applied to img tag (as a string seperated by space or an array of strings)
$emoji->getImage(':sunny:', 'emoji sunny'); // returns '<img src="//twemoji.maxcdn.com/16x16/2600.png" alt="black sun with rays" class="emoji sunny">'
Testing
$ phpspec
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 14.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-22