DEDECMS图片自动加上标题alt标签
2012-09-02 来源:未知
对于图片为何要加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,}[sS]{0,}["'s] @isU"," ",$this->Fields['body']);
$this->Fields['body'] = str_ireplace("<img " ,"<img alt="".$this->Fields['title']."" ",$this->Fields['body']);
这个是批量替换字段,更新生成就可以了。
相关内容资料: