DedeCMS5.7文章图片alt自动调用文章标题的修改方法

在网站中图片有alt无论是对网站还是对搜索引擎都是有好处的,之前给也大家介绍过,但是想要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');
后面加上如下代码:
//替换文章BODY 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']);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/98336c0918b7fe25ad152aea24e56836.html