<var id="xvh3p"><noframes id="xvh3p"><var id="xvh3p"></var><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing>
<var id="xvh3p"><strike id="xvh3p"><var id="xvh3p"></var></strike></var><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<span id="xvh3p"><noframes id="xvh3p"><dl id="xvh3p"></dl>
<span id="xvh3p"><noframes id="xvh3p">
<dl id="xvh3p"><noframes id="xvh3p">
<listing id="xvh3p"><noframes id="xvh3p"><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<th id="xvh3p"><strike id="xvh3p"></strike></th>
<dl id="xvh3p"><noframes id="xvh3p">
<th id="xvh3p"><noframes id="xvh3p">

观点

互联网+时代,说建站,谈运营与网络营销

织梦系统强化seo效果 dedecms网站用标签实现图片自动Alt功能

时间:2020-12-16

在我们用dedecms做网站的时候,在网站中有时候经常会插入图片,尤其是那些使用图片类型织梦模板的站长同志们,织梦在使用图片集时会用到很多的图片,这时候我们为了达到对每个图片的SEO优化效果,我们需要去对每个图片添加Alt标签注释,但是如果图片很多的话,手动去增加alt标签就会很很费时费力,而且图片都是围绕标题来的,基本上添加的alt便签也和文章的标题都差不多,我们为了简单起见,想到可以让文章或者是图片集里的图片在添加上去之后自动把alt标签注释改为文章的标题,这样省时又省事,又能够起到增加alt标签增强seo优化的效果。
    接下来,我们来看看具体的操作方式,共有四步:
 
第一步,在织梦dedecms网站的根目录下,打开源代码文件:Include/ arc.archives.class.php
 
第二步,在这个文件中查找下面的代码:     
 
@SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],'archives'); 
第三步:把上面这段代码修改为下面代码:
 
$this->Fields['body'] = str_ireplace(array('altalt=""','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('altalt=""','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']); 
第四步,保存文件刷新
 
0
首页
案例
关于
联系