After Zblog uploads an image and inserts it into an article, the alt attribute of the image uses the file name before the image is uploaded, and the image name often uses English or numbers. As an important tag attribute in SEO, if you use meaningless attribute values, it obviously meets the requirements of SEO, but it will take a lot of time to manually modify one by one, Therefore, it is very necessary to automatically add alt attribute values to zblog article images.
In the include.php file of the theme, add the code:
function qiteen_ setImgAlt(&$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);}
ActivePlugin in the include.php file_ Add code to the function:
Add_ Filter_ Plugin('Filter_Plugin_ViewPost_Template','qiteen_setImgAlt');
After saving the file, update the cache.