<下面给大家介绍WordPress 评论中嵌入图片的方法,希望对需要的朋友有所帮助!</p><p>有时发表评论需要添加图片,而WordPress本身并不具备评论贴图功能,可以将下面的代码添加到当前主题functions.php文件中:
</p><table border="1" cellspacing="1" cellpadding="1"><tbody><tr><td>add_action('comment_text', 'comments_embed_img', 2);<p>function comments_embed_img($comment) {</p><p>$size = auto;</p><p>$comment = preg_replace(array('#(http://([^\s]*)\.(jpg|gif|png|JPG|GIF|PNG))#','#(https://([^\s]*)\.(jpg|gif|png|JPG|GIF|PNG))#'),'<img src="/$1" ></p></td></tr></tbody></table>