经过百度的SEO检测发现,图片建议加入alt属性。万能的wordpress额,一搜索就有相应的答案了,记录如下。

function photo_alt($c) {
global $post;//全局量
$title = $post->post_title;//文章标题
$s = array('/src="(.+?.(jpg|bmp|png|jepg|gif))"/i' => 'src="$1" alt="'.$title.'"');
foreach($s as $p => $r){
$c = preg_replace($p,$r,$c);
}
return $c;
}
add_filter( 'the_content', 'photo_alt' );