织梦dedecms给图片添加Alt和Title属性


搜索引擎对织梦dedecms图片的认知就是图片添加的属性,在织梦后天上传图片的时候是不会添加属性的,虽然也有title选项,但是是没有效果的,想要添加属性还要在配置文件中做出相应的修改。

打开include/arc.archives.class.php文件

找到以下代码(一般在第204行):

//设置全局环境变量

$this->Fields[‘typename’] = $this->TypeLink->TypeInfos[‘typename’];

@SetSysEnv($this->Fields[‘typeid’],$this->Fields[‘typename’],$this->Fields[‘id’],$this->Fields[‘title’],’archives’);

}

//完成附加表信息读取

unset($row);

然后在

@SetSysEnv($this->Fields[‘typeid’],$this->Fields[‘typename’],$this->Fields[‘id’],$this->Fields[‘title’],’archives’); 

下面添加以下代码(“织梦中国网”就是你想要更换的图片名称):

$this->Fields[‘body’] = str_ireplace(”<img ” ,”<img alt='”.$this->Fields[‘title’].”,织梦中国网’ “,$this->Fields[‘body’]);

$this->Fields[‘imgurls’] = str_ireplace(”<img ” ,”<img alt='”.$this->Fields[‘title’].”,织梦中国网’ “,$this->Fields[‘imgurls’]);

$this->Fields[‘introduce’] = str_ireplace(”<img ” ,”<img alt='”.$this->Fields[‘title’].”,织梦中国网’ “,$this->Fields[‘introduce’]);