表情下载

此处内容需要评论回复后(审核通过)方可阅读。

教程

本站用的是cuteen主题,别的主题可能位置不同
1.下载表情到/usr/theme/Cuteen/static/emoji/文件夹下
添加表情文件夹
2.修改emoji.json文件
[quote color="danger"]把下面代码里的:###:替换为::(不然解析不到)[/quote]

,
    "贴图": {
        "type": "image",
        "container":[
     
            {
                "icon":"emoji/bqtt/101.jpg",
                "data":":###:(101)",
                "text":"101"
            },
            {
                "icon":"emoji/bqtt/102.jpg",
                "data":":###:(102)",
                "text":"102"
            },
            {
                "icon":"emoji/bqtt/103.jpg",
                "data":":###:(103)",
                "text":"103"
            },
            {
                "icon":"emoji/bqtt/104.jpg",
                "data":":###:(104)",
                "text":"104"
            },
            {
                "icon":"emoji/bqtt/105.jpg",
                "data":":###:(105)",
                "text":"105"
            },
            {
                "icon":"emoji/bqtt/106.jpg",
                "data":":###:(106)",
                "text":"106"
            },
            {
                "icon":"emoji/bqtt/107.jpg",
                "data":":###:(107)",
                "text":"107"
            },
            {
                "icon":"emoji/bqtt/108.jpg",
                "data":":###:(108)",
                "text":"108"
            },
            {
                "icon":"emoji/bqtt/109.jpg",
                "data":":###:(109)",
                "text":"109"
            },
            {
                "icon":"emoji/bqtt/110.jpg",
                "data":":###:(110)",
                "text":"110"
            },
            {
                "icon":"emoji/bqtt/201.jpg",
                "data":":###:(201)",
                "text":"201"
            },
            {
                "icon":"emoji/bqtt/202.jpg",
                "data":":###:(202)",
                "text":"202"
            },
            {
                "icon":"emoji/bqtt/203.jpg",
                "data":":###:(203)",
                "text":"203"
            },
            {
                "icon":"emoji/bqtt/204.jpg",
                "data":":###:(204)",
                "text":"204"
            },
            {
                "icon":"emoji/bqtt/205.jpg",
                "data":":###:(205)",
                "text":"205"
            },
            {
                "icon":"emoji/bqtt/206.jpg",
                "data":":###:(206)",
                "text":"206"
            },
            {
                "icon":"emoji/bqtt/207.jpg",
                "data":":###:(207)",
                "text":"207"
            },
            {
                "icon":"emoji/bqtt/208.jpg",
                "data":":###:(208)",
                "text":"208"
            },
            {
                "icon":"emoji/bqtt/209.jpg",
                "data":":###:(209)",
                "text":"209"
            },
            {
                "icon":"emoji/bqtt/210.jpg",
                "data":":###:(210)",
                "text":"210"
            },
            {
                "icon":"emoji/bqtt/401.jpg",
                "data":":###:(401)",
                "text":"401"
            },
            {
                "icon":"emoji/bqtt/402.jpg",
                "data":":###:(402)",
                "text":"402"
            },
            {
                "icon":"emoji/bqtt/403.jpg",
                "data":":###:(403)",
                "text":"403"
            },
            {
                "icon":"emoji/bqtt/404.jpg",
                "data":":###:(404)",
                "text":"404"
            },
            {
                "icon":"emoji/bqtt/405.jpg",
                "data":":###:(405)",
                "text":"405"
            },
            {
                "icon":"emoji/bqtt/406.jpg",
                "data":":###:(406)",
                "text":"406"
            },
            {
                "icon":"emoji/bqtt/407.jpg",
                "data":":###:(407)",
                "text":"407"
            },
            {
                "icon":"emoji/bqtt/408.jpg",
                "data":":###:(408)",
                "text":"408"
            },
            {
                "icon":"emoji/bqtt/409.jpg",
                "data":":###:(409)",
                "text":"409"
            },
            {
                "icon":"emoji/bqtt/410.jpg",
                "data":":###:(410)",
                "text":"410"
            }
        ]
        }

在倒数第二个}后面添加
添加json数据
3.修改inc文件夹下的ctx.php,搜索$content = preg_replace_callback(找到表情解析的地方
添加解析
添加以下代码

    $content = preg_replace_callback(
        '/\:\:\(\s*(101|102|103|104|105|106|107|108|109|110|201|202|203|204|205|206|207|208|209|210|301|302|303|304|305|306|307|308|309|310|401|402|403|404|405|406|407|408|409|410)\s*\)/is',
        array('Ctx','Parsebqtt'),
        $content
    );

再找到下面几行带有回调函数的注释,添加以下代码
添加回调函数

//贴图回调函数
private static function Parsebqtt($match)
{
    return '<img class="emotion-bqtt" src="' . StaticPath . '/emoji/bqtt/' . str_replace('%', '',urldecode($match[1])) . '.jpg">';
}

再到后台css,添加

.emotion-bqtt{width:80px;}

刷新服务器缓存和浏览器缓存,再次点开表情,发现添加成功

最后修改:2021 年 07 月 14 日 02 : 33 PM
如果觉得我的文章对你有用,请随意赞赏