拓展自定义表情功能至支持表情和表情包两种类型的表情 - #1417
Open
HuajiMX wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
原自定义表情仅支持emoji类的表情,不支持表情包。现拓展了表情包类型表情的适配,同时向下兼容原表情系统。
主要改动
functions.php
get_custom_smilies_list函数中,第 ~1475 行表情文件按
{name}_{type: 0/1}.{extension}的格式命名,php 代码内分割相应成分。type为 0 表示 emoji 类型,为 1 表示 meme 类型。push_custom_smilies函数(第 ~1549 行)function push_custom_smilies() { global $custom_smiliestrans; - $custom_smilies_panel = ''; + + // 拓展自定义表情类型 + $custom_smilies_emoji_panel = ''; + $custom_smilies_meme_panel = ''; $custom_smilies_list = get_custom_smilies_list(); if (!$custom_smilies_list) { $custom_smilies_panel = '<div style="font-size: 20px;text-align: center;width: 300px;height: 100px;line-height: 100px;">File does not exist!</div>'; return $custom_smilies_panel; } $custom_smilies_cdn = iro_opt('smilies_proxy'); foreach ($custom_smilies_list as $smiley) { if ($custom_smilies_cdn) { $smiley_url = $custom_smilies_cdn . $smiley['little_path']; } else { $smiley_url = $smiley['file_url']; } - $custom_smilies_panel = $custom_smilies_panel . '<span title="' . $smiley['base_name'].'" ' . make_onclick_grin($smiley['base_name'],'Math').'><img alt="custom_smilies" loading="lazy" style="height: 60px;" src="' . $smiley_url . '" /></span>'; - $custom_smiliestrans['{{' . $smiley['base_name'] . '}}'] = '<span title="' . $smiley['base_name'] . '" ><img alt="custom_smilies" loading="lazy" style="height: 60px;" src="' . $smiley_url . '" /></span>'; + // 拓展自定义表情类型,按不同样式展示(emoji正常表情样式,meme按大图表情包展示,独占一行) + if($smiley['type'] === 'emoji') { + $custom_smilies_emoji_panel = $custom_smilies_emoji_panel . '<span title="' . $smiley['base_name'].'" ' . make_onclick_grin($smiley['base_name'],'Math').'><img alt="custom_smilies" class="custom-smilies-type-emoji" loading="lazy" src="' . $smiley_url . '" /></span>'; + $custom_smiliestrans['{{' . $smiley['base_name'] . '}}'] = '<span title="' . $smiley['base_name'] . '" ><img alt="custom_smilies" class="smilie-emoji-in-content" loading="lazy" src="' . $smiley_url . '" /></span>'; + } else if($smiley['type'] === 'meme') { + $custom_smilies_meme_panel = $custom_smilies_meme_panel . '<span title="' . $smiley['base_name'].'" ' . make_onclick_grin($smiley['base_name'],'Math').'><img alt="custom_smilies" class="custom-smilies-type-meme" loading="lazy" src="' . $smiley_url . '" /></span>'; + $custom_smiliestrans['{{' . $smiley['base_name'] . '}}'] = '<span title="' . $smiley['base_name'] . '" ><img alt="custom_smilies" loading="lazy" style="height: 100px; display: block; margin: 5px; border-radius: 5px;" src="' . $smiley_url . '" /></span>'; } } + // 两种表情在面板上分开展示 + $custom_smilies_panel = $custom_smilies_emoji_panel . ($custom_smilies_emoji_panel ? '<br>' : '') . $custom_smilies_meme_panel; return $custom_smilies_panel; }按不同表情类型分别设置面板中显示样式和正文中展示样式。同时在表情面板中按 emoji 在前,meme 在后的顺序分离展示两种表情。
style.css
主要是对两种不同自定义表情的面板样式进行适配优化。
这里优化了 emoji 类表情(包括模板内置表情)在正文内的垂直对齐位置,原先的表情位置相比正文文字较为靠上,调整后与正文视觉上居中平齐,效果更好。