WordPress是不支持在评论中插入图片的,有时候留言评论时需要插入图片,或者我们自开发主题时,在评论时加入贴图功能,一起看下面的步骤来实现
1、在functions.php中加入以下代码
/*
*评论中插入图片
*/
add_action('comment_text','comments_embed_img',2);
function comments_embed_img($comment) {
$size = auto;
$comment = preg_replace(array('#(http://([^s]*).(jpg|gif|png|JPG|GIF|PNG))#','#(https://([^s]*).(jpg|gif|png|JPG|GIF|PNG))#'),'
return $comment;
}
这样的话,你只要在评论中插入图片地址,就能显示图片了。
2、添加贴图按钮链接
在你的comments.php评论模板样式文件中,添加一个按钮或链接: