This commit is contained in:
浪子 2025-07-07 17:30:50 +08:00
parent 58b2e80883
commit 33bc5d53f5
4 changed files with 56 additions and 3 deletions

View File

@ -32,4 +32,10 @@
- 增加系统显示设置
- 增加浏览器信息显示设置
- 修复pjax模式下的404跳转
---
### 2024-07-07 表情短代码解析集成
- 1.1.5
- 将表情短代码(如 :smile:)自动解析为图片表情,集成到主题评论内容输出中。

View File

@ -178,7 +178,7 @@
</div>
<div class="content">
<div class="content-text t-md mt10 puock-text">
<?php if ($comments->parent) {echo getPermalinkFromCoid($comments->parent);} $comments->content();?>
<?php if ($comments->parent) {echo getPermalinkFromCoid($comments->parent);} echo parse_smiley_shortcode($comments->content);?>
<div class="comment-os c-sub">
<?php
$deviceInfo = getBrowsersInfo($comments->agent);

View File

@ -918,4 +918,51 @@ class AttachmentHelper {
<?php
}
}
/**
* 解析表情短代码为图片
* @param string $content
* @return string
*/
function parse_smiley_shortcode($content) {
$smileys = [
':?:' => 'doubt.png',
':razz:' => 'razz.png',
':sad:' => 'sad.png',
':evil:' => 'evil.png',
':naughty:' => 'naughty.png',
':!:' => 'scare.png',
':smile:' => 'smile.png',
':oops:' => 'oops.png',
':neutral:' => 'neutral.png',
':cry:' => 'cry.png',
':mrgreen:' => 'mrgreen.png',
':grin:' => 'grin.png',
':eek:' => 'eek.png',
':shock:' => 'shock.png',
':???:' => 'bz.png',
':cool:' => 'cool.png',
':lol:' => 'lol.png',
':mad:' => 'mad.png',
':twisted:' => 'twisted.png',
':roll:' => 'roll.png',
':wink:' => 'wink.png',
':idea:' => 'idea.png',
':despise:' => 'despise.png',
':celebrate:' => 'celebrate.png',
':watermelon:' => 'watermelon.png',
':xmas:' => 'xmas.png',
':warn:' => 'warn.png',
':rainbow:' => 'rainbow.png',
':loveyou:' => 'loveyou.png',
':love:' => 'love.png',
':beer:' => 'beer.png',
];
$themeUrl = Helper::options()->themeUrl . '/assets/img/smiley/';
foreach ($smileys as $code => $img) {
$imgTag = '<img class="smiley-img" src="' . $themeUrl . $img . '" alt="' . $code . '" title="表情" style="width:24px;height:24px;vertical-align:middle;" />';
$content = str_replace($code, $imgTag, $content);
}
return $content;
}
?>

View File

@ -4,7 +4,7 @@
*
* @package Typecho Pouck Theme
* @author 老孙博客
* @version 1.1.4
* @version 1.1.5
* @link http://www.imsun.org
*/