首页 > 教程 >

织梦dedecms将文章和图集里图片的ALT注释修改为文章标题

2023-02-25教程围观

简介织梦dedecms将文章和图集里图片的ALT注释修改为文章标题。打开include/arc.archives.class.php文件找到$this->Fields['typename']=$this->TypeLink->TypeInfos['typename'];@SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this-

  

织梦dedecms将文章和图集里图片的ALT注释修改为文章标题。

打开 include/arc.archives.class.php 文件
 
找到
 
$this->Fields['typename'] = $this->Type ->TypeInfos['typename'];@SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields[' '],'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[' ']."" ",$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,}[sS]{0,}["'s] @isU"," ",$this->Fields['imgurls']);$this->Fields['imgurls'] = str_ireplace("<img " ,"<img alt="".$this->Fields[' ']."" ",$this->Fields['imgurls']);

下载链接:网站源码/小程序源码/网站模板下载

Tags: 织梦 文章 图片 图集 标题