function autoimgalt(&$template){
global $zbp;
$article = $template->GetTags('article');
$pattern = "/<img(.*?)src=('|\")([^>]*).(bmp|gif|jpeg|jpg|png|swf)('|\")(.*?)>/i";
$replacement = '<img alt="'.$article->Title.'" src=$2$3.$4$5/>';
$content = preg_replace($pattern, $replacement, $article->Content);
$article->Content = $content;
$template->SetTags('article', $article);
}这里我们需要到当前的ZBLOG PHP主题的"include.php"文件中添加代码。
Add_Filter_Plugin('Filter_Plugin_ViewPost_Template','autoimgalt');然后我们需要在主题的激活接口添加(ActivePlugin_主题ID())。