富文本图片和视频标签增加域名前缀

1
2
3
4
5
6
7
8
9
10
11
12
13
public function getContentAttr($value, $data)
{
        if (isset($data['content']) && !empty($data['content'])) {
            $content = $data['content'];
            $content = str_replace("http://xfcyjs.maoln.com", "", $content);
            $content = str_replace("<img src=\"/uploads", "<img style=\"width: 100%;!important\" src=\"" . request()->domain() . "/uploads", $content);
            $content = str_replace("<video src=\"/uploads", "<video style=\"width: 100%;!important\" src=\"" . request()->domain() . "/uploads", $content);
        } else {
            $content = '';
        }
 
        return $content;
}
posted @   U丶Zero  阅读(445)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示