推荐:织梦系统文章图片ALT自动调用标题的方法

 alt描述也算是在网站SEO优化的一个细节,今天给大家分享一下织梦dedecms文章、软件、图集的图片ALT自动变成完整标题(Title),减少人工修改的时间,全部自动生成标题全称”的方法。

    首先大家找到 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']);
 
  这样改好了,就不用每次自己手动去添加了。经测试,完美可用!