dedecms织梦图片alt标签自动调用title属性

织梦dedeCMS优化(SEO优化)的细节真的特别的多,其中 织梦dedeCMS自带的图片上传就有ALT添加的地方。
 
  不过今天主要说说以图片为主的图片站,若图片在较多的情况下,且站长又是个比较懒的人,则建议使用以下方法(使用以下方法后DEDECMS图片会自动将标题设为alt标签):
 
  首页找到目录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');
  在下面添加:
//替换图片Alt为文档标题
$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']);
 
  OK, 织梦dedeCMS修改过之后在更新生成下文章内容就可以了,方法其实很简单。