• 0
  • 0

帖子详情显示 base64图片

2021-03-08 830 0 admin 所属分类:Discuz
function viewthread_bottom_output() {
    global $_G, $postlist;
    foreach($postlist as $k = > $v) {
        // 转换base64文件
        if (preg_match_all("/<img[\s\S]+?file=\"([\s\S]+?)\"[\s\S]+?\/>/is", $v['message'], $matches)) {
            foreach($matches[1] as $m = > $match) {
                if (strpos($match, "data:image/") !== false) {
                    $t = str_replace($match, str_replace(['http://', 'https://'], '', $match), $matches[0][$m]);
                    $t = str_replace("file=", "src=", $t);
                    $v['message'] = str_replace($matches[0][$m], $t, $v['message']);
                }
            }
        }
    }
    return [];
}


返回顶部