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);}
Add code to the ActivePlugin_ function in the include.php file:
Add_Filter_Plugin('Filter_Plugin_ViewPost_Template','qiteen_setImgAlt');
After saving the file, update the cache.