tagGenerator / config |
Output |
none (direct Browser output)
// The variable $testString in the following code sections
// corresponds to the following string:
"I could eat 11οΈβ£ π right now! π€€ π§πΎββοΈπ©πΏπͺπΊππ»ββοΈπββοΈ"
|
I could eat 11οΈβ£ π right now! π€€ π§πΎββοΈπ©πΏπͺπΊππ»ββοΈπββοΈ |
default (with default preset "twemoji_72")
$Phmiley->parse($testString)
|
I could eat 1 right now!      I could eat 1<img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/31-20e3.png" style="height:1em;width:auto;vertical-align:text-bottom;"> <img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f355.png" style="height:1em;width:auto;vertical-align:text-bottom;"> right now! <img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f924.png" style="height:1em;width:auto;vertical-align:text-bottom;"> <img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f9ce-1f3fe-200d-2642-fe0f.png" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f469-1f3ff.png" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f1ea-1f1fa.png" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f3c3-1f3fb-200d-2640-fe0f.png" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/72x72/1f3c3-200d-2640-fe0f.png" style="height:1em;width:auto;vertical-align:text-bottom;">
|
default (with preset "twemoji_svg")
$Phmiley->setPreset("twemoji_svg");
$Phmiley->parse($testString);
|
I could eat 1 right now!      I could eat 1<img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/31-20e3.svg" style="height:1em;width:auto;vertical-align:text-bottom;"> <img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f355.svg" style="height:1em;width:auto;vertical-align:text-bottom;"> right now! <img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f924.svg" style="height:1em;width:auto;vertical-align:text-bottom;"> <img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f9ce-1f3fe-200d-2642-fe0f.svg" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f469-1f3ff.svg" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f1ea-1f1fa.svg" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f3c3-1f3fb-200d-2640-fe0f.svg" style="height:1em;width:auto;vertical-align:text-bottom;"><img src="https://gitcdn.xyz/repo/twitter/twemoji/master/assets/svg/1f3c3-200d-2640-fe0f.svg" style="height:1em;width:auto;vertical-align:text-bottom;">
|
default (with preset "openmoji_svg")
$Phmiley->setPreset("openmoji_svg");
$Phmiley->parse($testString);
|
I could eat 1 right now!      I could eat 1<img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/0031-FE0F-20E3.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F355.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> right now! <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F924.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F9CE-1F3FE-200D-2642-FE0F.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F469-1F3FF.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F1EA-1F1FA.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F3C3-1F3FB-200D-2640-FE0F.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/svg/1F3C3-200D-2640-FE0F.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;">
|
default (with preset "openmoji_72")
$Phmiley->setPreset("openmoji_72");
$Phmiley->parse($testString);
|
I could eat 1 right now!      I could eat 1<img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/0031-FE0F-20E3.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F355.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"> right now! <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F924.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F9CE-1F3FE-200D-2642-FE0F.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F469-1F3FF.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F1EA-1F1FA.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F3C3-1F3FB-200D-2640-FE0F.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/72x72/1F3C3-200D-2640-FE0F.png" style="height:1.3em;width:auto;vertical-align:text-bottom;">
|
default (with preset "openmoji_618")
$Phmiley->setPreset("openmoji_618");
$Phmiley->parse($testString);
|
I could eat 1 right now!      I could eat 1<img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/0031-FE0F-20E3.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F355.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"> right now! <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F924.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F9CE-1F3FE-200D-2642-FE0F.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F469-1F3FF.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F1EA-1F1FA.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F3C3-1F3FB-200D-2640-FE0F.png" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji@12.3.0/color/618x618/1F3C3-200D-2640-FE0F.png" style="height:1.3em;width:auto;vertical-align:text-bottom;">
|
default (with custom options, e.g. local emoji images)
$Phmiley->imgBase = "./example-images/";
$Phmiley->imgExt = "svg";
$Phmiley->codeUppercase = true;
$Phmiley->parse($testString);
|
I could eat 1 right now!      I could eat 1<img src="./example-images/0031-FE0F-20E3.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="./example-images/1F355.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> right now! <img src="./example-images/1F924.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> <img src="./example-images/1F9CE-1F3FE-200D-2642-FE0F.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="./example-images/1F469-1F3FF.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="./example-images/1F1EA-1F1FA.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="./example-images/1F3C3-1F3FB-200D-2640-FE0F.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"><img src="./example-images/1F3C3-200D-2640-FE0F.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;">
|
custom
$Phmiley->tagGenerator = function($data) {
return $data['emoji']
. ' => <span style="outline: solid red 1px;">'
. $data['code']
. '</span>';
};
|
I could eat 11οΈβ£ => 31-fe0f-20e3 π => 1f355 right now! π€€ => 1f924 π§πΎββοΈ => 1f9ce-1f3fe-200d-2642-fe0fπ©πΏ => 1f469-1f3ffπͺπΊ => 1f1ea-1f1faππ»ββοΈ => 1f3c3-1f3fb-200d-2640-fe0fπββοΈ => 1f3c3-200d-2640-fe0f I could eat 11οΈβ£ => <span style="outline: solid red 1px;">31-fe0f-20e3</span> π => <span style="outline: solid red 1px;">1f355</span> right now! π€€ => <span style="outline: solid red 1px;">1f924</span> π§πΎββοΈ => <span style="outline: solid red 1px;">1f9ce-1f3fe-200d-2642-fe0f</span>π©πΏ => <span style="outline: solid red 1px;">1f469-1f3ff</span>πͺπΊ => <span style="outline: solid red 1px;">1f1ea-1f1fa</span>ππ»ββοΈ => <span style="outline: solid red 1px;">1f3c3-1f3fb-200d-2640-fe0f</span>πββοΈ => <span style="outline: solid red 1px;">1f3c3-200d-2640-fe0f</span>
|
custom (only repalce regional indicator symbols / flags)
$Phmiley->tagGenerator = function($data) use ($Phmiley) {
if (!preg_match("/[\x{1F1E6}-\x{1F1FF}]/u", $data['emoji'])) {
return $data['emoji'];
} else {
return $Phmiley->defaultTagGenerator($data);
}
};
|
I could eat 11οΈβ£ π right now! π€€ π§πΎββοΈπ©πΏ ππ»ββοΈπββοΈ I could eat 11οΈβ£ π right now! π€€ π§πΎββοΈπ©πΏ<img src="./example-images/1F1EA-1F1FA.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;">ππ»ββοΈπββοΈ
|
custom (replace images that are not found via JavaScript)
$Phmiley->tagGenerator = function($data) use ($Phmiley) {
$code = $Phmiley->codeUppercase ? strtoupper($data['code']) : $data['code'];
return '<img
src="' . $Phmiley->imgBase . $code . '.' . $Phmiley->imgExt . '"
style="height:' . ($Phmiley->imgHeight ?? '1em') . ';width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode(\'[missing: ' . $data['emoji'] . ']\'), this);"
>';
};
|
I could eat 1
right now!
I could eat 1
<img
src="./example-images/31-FE0F-20E3.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: 1οΈβ£]'), this);"
>
<img
src="./example-images/1F355.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: π]'), this);"
>
right now!
<img
src="./example-images/1F924.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: π€€]'), this);"
>
<img
src="./example-images/1F9CE-1F3FE-200D-2642-FE0F.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: π§πΎββοΈ]'), this);"
>
<img
src="./example-images/1F469-1F3FF.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: π©πΏ]'), this);"
>
<img
src="./example-images/1F1EA-1F1FA.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: πͺπΊ]'), this);"
>
<img
src="./example-images/1F3C3-1F3FB-200D-2640-FE0F.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: ππ»ββοΈ]'), this);"
>
<img
src="./example-images/1F3C3-200D-2640-FE0F.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.parentNode.replaceChild(document.createTextNode('[missing: πββοΈ]'), this);"
>
|
custom (remove images that are not found via JavaScript)
$Phmiley->tagGenerator = function($data) use ($Phmiley) {
$code = $Phmiley->codeUppercase ? strtoupper($data['code']) : $data['code'];
return '<img
src="' . $Phmiley->imgBase . $code . '.' . $Phmiley->imgExt . '"
style="height:' . ($Phmiley->imgHeight ?? '1em') . ';width:auto;vertical-align:text-bottom;"
onerror="this.remove();"
>';
};
|
I could eat 1
right now!
I could eat 1
<img
src="./example-images/31-FE0F-20E3.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
<img
src="./example-images/1F355.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
right now!
<img
src="./example-images/1F924.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
<img
src="./example-images/1F9CE-1F3FE-200D-2642-FE0F.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
<img
src="./example-images/1F469-1F3FF.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
<img
src="./example-images/1F1EA-1F1FA.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
<img
src="./example-images/1F3C3-1F3FB-200D-2640-FE0F.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
<img
src="./example-images/1F3C3-200D-2640-FE0F.svg"
style="height:1.3em;width:auto;vertical-align:text-bottom;"
onerror="this.remove()"
>
|
custom (only replace if local image exists)
$Phmiley->tagGenerator = function($data) use ($Phmiley) {
$code = $Phmiley->codeUppercase ? strtoupper($data['code']) : $data['code'];
$emojiFile = $Phmiley->imgBase . $code . '.' . $Phmiley->imgExt;
if (!is_file($emojiFile)) {
return $data['emoji'];
}
return $Phmiley->defaultTagGenerator($data);
};
|
I could eat 11οΈβ£ right now! π§πΎββοΈπ©πΏ ππ»ββοΈπββοΈ I could eat 11οΈβ£ <img src="./example-images/1F355.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> right now! <img src="./example-images/1F924.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;"> π§πΎββοΈπ©πΏ<img src="./example-images/1F1EA-1F1FA.svg" style="height:1.3em;width:auto;vertical-align:text-bottom;">ππ»ββοΈπββοΈ
|