织梦文章和图集里图片自动ALT注释为文章标题

网站建设 2022-07-27 08:13www.1681989.com免费网站
在织梦目录里打开 clude/arc.archives.class.php 文件 找到 $this-Fields[typename] = $this-TypeLk-TypeInfos[typename]; @SetSysEnv($this-Fields[typeid],$this-Fields[typename],$this-Fields[id],$this-Fields[title],archives); 在其下边添加 //文章模板中的图片自动添加alt属性为标题 $this-Fields[bo […]



在织梦目录里打开 clude/arc.archives.class.php 文件

找到

$this->Fields['typename'] = $this->TypeLk->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']);

 

//图集模板中的图片自动添加注释为标题
 

$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']);

 

Copyright © 2016-2025 www.1681989.com 推火网 版权所有 Power by