评论发图片后刷新不显示图片。

2016-06-13 21:28:36 +08:00
 wwpp
完成后贴入图片网址,提交可以显示,但是刷新就不能显示图片了~ 而且 HTM 图片代码变成
<img data-original=" " alt="" />

怎么破?求大大们帮帮看看啊


根据以下代码

function auto_comment_image( $comment ) {// by http://mufeng.me
$post_ID = $comment["comment_post_ID"];
if($post_ID == 972){ //此处为页面 id
global $allowedtags;
$content = $comment["comment_content"];
 
// alt 部分自行填写
$content = preg_replace('/( http:\/\/|https:\/\/){1}.+?\.(jpg|gif|bmp|bnp|png)$/is','<img src="http://mufeng.me/$0" alt="" />',$content);
 
//允许发布 img 标签
$allowedtags['img'] = array('src' => array (), 'alt' => array ());
 
// 重新给$comment 赋值
$comment["comment_content"] = $content;
}
return $comment;
}
add_filter('preprocess_comment', 'auto_comment_image');
2046 次点击
所在节点    WordPress
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/285454

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX