对于一个SEO高手来说,每个细节都相当重要。本文介绍如何将文章里的图片的注释改成文章标题,如此一来,对搜索引擎会更加友好。如果只想加文章的就把带imgurls的三行去掉即可。
修改文件:Include/ arc.archives.class.php
查找以下代码:
$this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];@SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],'archives');
$this->Fields['body'] = str_ireplace(array('alt=""','alt=/'/''),'',$this->Fields['body']);$this->Fields['body'] = preg_replace("@ [/s]{0,}alt[/s]{0,}=[/"'/s]{0,}[/s/S]{0,}[/"'/s] @isU"," ",$this->Fields['body']);$this->Fields['body'] = str_ireplace("<img " ,"<img alt=/"".$this->Fields['title']."/" ",$this->Fields['body']);$this->Fields['imgurls'] = str_ireplace(array('alt=""','alt=/'/''),'',$this->Fields['imgurls']);$this->Fields['imgurls'] = preg_replace("@ [/s]{0,}alt[/s]{0,}=[/"'/s]{0,}[/s/S]{0,}[/"'/s] @isU"," ",$this->Fields['imgurls']);$this->Fields['imgurls'] = str_ireplace("<img " ,"<img alt=/"".$this->Fields['title']."/" ",$this->Fields['imgurls']);//替换图片Alt为文档标题
改完以后直接生成全站就OK了,对图片多的站来说还是很重要的,图片的alt标签不容忽视。生成以后我发现一个问题,就是图片的注变成了alt='文章标题' 但是百度的规范应该是 alt="文章标题"。
解决方法: 你代码的最后一行
$this->Fields['body'] = str_ireplace("<img " ,"<img alt='".$this->Fields['title']."' ",$this->Fields['body']);
$this->Fields['body'] = str_ireplace("<img " ,"<img alt=/"".$this->Fields['title']."/" ",$this->Fields['body']);
如果本文对你有帮助,欢迎打赏本站