DedeCMS织梦模板为图片自动添加ALT属性为文章标题

  织梦默认的文章图片属性是要自己手动添加的,否则为空,这对网编来说太过于麻烦,而seo又要求图片alt属性一定要全,文章图片的alt属性一般跟标题一样。

  所以余斗就想办法实现了自动添加图片的alt属性,属性内容为文章标题,具体方法为:

  修改文件:Include/ arc.archives.class.php

  模板标签:

  {dede:field.body/}

  如果是其它字段,可以修改

  $this->Fields[‘body’]

  效率说明:使用了正则处理,会降低一些生成速度,如果数据量小,则可以忽略。

  修改方法:

  首先查找打开include/ arc.archives.class.php

  查找:

  //设置全局环境变量

  $this->Fields[‘typename’] = $this->TypeLink->TypeInfos[‘typename’];

  SetSysEnv($this->Fields[‘typeid’],$this->Fields[‘typename’],$this->Fields[‘aid’],$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,}[sS]{0,}[“‘s] @isU”,” “,$this->Fields[‘body’]);

  $this->Fields[‘body’] = str_ireplace(“".$this->Fields[‘title’].”‘ “,$this->Fields[‘body’]);</p>
<p>  保存,然后重新生成文章,即可实现文章中图片ALT属性自动以文章标题添加的功能。</p>
</div>
<div id="pay-single-box"></div>
<div class="entry-tags">
<a href="https://www.dhtlly.com/tag/dedecms" rel="tag">
dedecms      </a>
<a href="https://www.dhtlly.com/tag/dede%e6%a8%a1%e6%9d%bf" rel="tag">
dede模板      </a>
<a href="https://www.dhtlly.com/tag/%e7%bb%87%e6%a2%a6%e6%a8%a1%e6%9d%bf" rel="tag">
织梦模板      </a>
</div>
<div class="article-copyright"><span style="color:#ff0000">☉免责声明:本站所有模板均来自用户分享和网络收集,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1131734965&site=qq&menu=yes">网站客服</a>,我们核实后会立即删除。</span>
<br/>
☉本站提供的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!<br/><a href="https://www.dhtlly.com">pbootcms模板网</a> » <a href="https://www.dhtlly.com/1083.html">DedeCMS织梦模板为图片自动添加ALT属性为文章标题</a></div>
<div class="article-footer">
<div class="xshare">
<span class="xshare-title">分享到:</span>
<a href="javascript:;" title="收藏文章" etap="star" data-postid="1083" class="ripro-star"><i class="fa fa-star-o"></i></a>
<a href="" etap="share" data-share="qq" class="share-qq"><i class="fa fa-qq"></i></a>
<a href="" etap="share" data-share="weibo" class="share-weibo"><i class="fa fa-weibo"></i></a>
</div>
<!--百度收录情况显示-->
百度已收录</div>    </div>
</div>
</article>
<div class="entry-navigation">
<nav class="article-nav">
<span class="article-nav-prev">上一篇<br><a href="https://www.dhtlly.com/1081.html" rel="prev">[精]织梦自定义表单中手机号码和邮箱的验证规则及必填项设置</a></span>
<span class="article-nav-next">下一篇<br><a href="https://www.dhtlly.com/1085.html" rel="next">DEDE织梦文章和列表页均使用拼音,使之更适合于SEO的解决方案</a></span>
</nav>
</div>
<!-- # 标准网格模式... -->
<div class="related-posts-grid">
<h4 class="u-border-title">相关推荐</h4>
<div class="row">
<div class="col-6 col-sm-3 col-md-3 mt-10 mb-10">
<article class="post">
<div class="entry-media">
<div class="placeholder" style="padding-bottom: 66.666666666667%;">
<a  href="https://www.dhtlly.com/1911.html">
<img class="lazyload" data-src="https://www.dhtlly.com/wp-content/themes/ripro/timthumb.php?src=https://www.dhtlly.com/wp-content/themes/ripro/assets/images/thumb/14.jpg&h=200&w=300&zc=1&a=c&q=100&s=1" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="织梦自定义表单提交后提示非法操作">  
</a>
</div>
<div class="entry-star"><a href="javascript:;" title="收藏文章" etap="star" data-postid="1911" class="ripro-star"><i class="fa fa-star-o"></i></a></div>  </div>
<div class="entry-wrapper">
<header class="entry-header">    
<h4 class="entry-title"><a href="https://www.dhtlly.com/1911.html" title="织梦自定义表单提交后提示非法操作" rel="bookmark">织梦自定义表单提交后提示非法操作</a></h4>  </header>                </div>
</article>
</div>
<div class="col-6 col-sm-3 col-md-3 mt-10 mb-10">
<article class="post">
<div class="entry-media">
<div class="placeholder" style="padding-bottom: 66.666666666667%;">
<a  href="https://www.dhtlly.com/669.html">
<img class="lazyload" data-src="https://www.dhtlly.com/wp-content/themes/ripro/timthumb.php?src=https://www.dhtlly.com/wp-content/themes/ripro/assets/images/thumb/15.jpg&h=200&w=300&zc=1&a=c&q=100&s=1" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="dedecms内容随机调用标签相关知识总结">  
</a>
</div>
<div class="entry-star"><a href="javascript:;" title="收藏文章" etap="star" data-postid="669" class="ripro-star"><i class="fa fa-star-o"></i></a></div>  </div>
<div class="entry-wrapper">
<header class="entry-header">    
<h4 class="entry-title"><a href="https://www.dhtlly.com/669.html" title="dedecms内容随机调用标签相关知识总结" rel="bookmark">dedecms内容随机调用标签相关知识总结</a></h4>  </header>                </div>
</article>
</div>
<div class="col-6 col-sm-3 col-md-3 mt-10 mb-10">
<article class="post">
<div class="entry-media">
<div class="placeholder" style="padding-bottom: 66.666666666667%;">
<a  href="https://www.dhtlly.com/853.html">
<img class="lazyload" data-src="https://www.dhtlly.com/wp-content/themes/ripro/timthumb.php?src=https://www.dhtlly.com/wp-content/themes/ripro/assets/images/thumb/6.jpg&h=200&w=300&zc=1&a=c&q=100&s=1" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="runphp标签织梦dedecms直接获取上一篇下一篇的URL网址链接">  
</a>
</div>
<div class="entry-star"><a href="javascript:;" title="收藏文章" etap="star" data-postid="853" class="ripro-star"><i class="fa fa-star-o"></i></a></div>  </div>
<div class="entry-wrapper">
<header class="entry-header">    
<h4 class="entry-title"><a href="https://www.dhtlly.com/853.html" title="runphp标签织梦dedecms直接获取上一篇下一篇的URL网址链接" rel="bookmark">runphp标签织梦dedecms直接获取上一篇下一篇的URL网址链接</a></h4>  </header>                </div>
</article>
</div>
<div class="col-6 col-sm-3 col-md-3 mt-10 mb-10">
<article class="post">
<div class="entry-media">
<div class="placeholder" style="padding-bottom: 66.666666666667%;">
<a  href="https://www.dhtlly.com/1329.html">
<img class="lazyload" data-src="https://www.dhtlly.com/wp-content/themes/ripro/timthumb.php?src=https://www.dhtlly.com/wp-content/themes/ripro/assets/images/thumb/1.jpg&h=200&w=300&zc=1&a=c&q=100&s=1" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="dedeCMS安装后数据表前缀的修改方法">  
</a>
</div>
<div class="entry-star"><a href="javascript:;" title="收藏文章" etap="star" data-postid="1329" class="ripro-star"><i class="fa fa-star-o"></i></a></div>  </div>
<div class="entry-wrapper">
<header class="entry-header">    
<h4 class="entry-title"><a href="https://www.dhtlly.com/1329.html" title="dedeCMS安装后数据表前缀的修改方法" rel="bookmark">dedeCMS安装后数据表前缀的修改方法</a></h4>  </header>                </div>
</article>
</div>
</div>
</div>
</main>
</div>
</div>
<div class="sidebar-column col-lg-3">
<aside class="widget-area">
<div id="search-2" class="widget widget_search"><form method="get" class="search-form inline" action="https://www.dhtlly.com/">
<input type="search" class="search-field inline-field" placeholder="输入关键词,回车..." autocomplete="off" value="" name="s" required="required">
<button type="submit" class="search-submit"><i class="mdi mdi-magnify"></i></button>
</form></div>
<div id="recent-posts-4" class="widget widget_recent_entries">
<h5 class="widget-title">近期文章</h5>
<ul>
<li>
<a href="https://www.dhtlly.com/5951.html">pbcms034(带手机端)蓝色铝合金电缆线缆生产企业类网站pbootcms模板 桥架钢结构五金机械网站源码</a>
</li>
<li>
<a href="https://www.dhtlly.com/5947.html">pbcms033(电脑手机同版)蓝色机械设备工业类网站pbootcms模板 企业生产设备网站源码</a>
</li>
<li>
<a href="https://www.dhtlly.com/5942.html">pbcms032(自适应手机端)蓝色工商企业管理咨询类网站pbootcms模板 企业咨询服务网站源码</a>
</li>
<li>
<a href="https://www.dhtlly.com/5936.html">pbcms031(自识别手机端)红色教育留学咨询企业类网站pbootcms模板 学历提升教育培训网站源码</a>
</li>
<li>
<a href="https://www.dhtlly.com/5931.html">pbcms030(自适应手机端)响应式瓷砖大理石建材类网站pbootcms模板 html5装修建材网站模板</a>
</li>
</ul>
</div><div id="cao_widget_comments-3" class="widget widget-comments"><ul></ul></div><div id="categories-2" class="widget widget_categories"><h5 class="widget-title">分类</h5><form action="https://www.dhtlly.com" method="get"><label class="screen-reader-text" for="cat">分类</label><select  name=

文章归档

Pbootcms模板网 提供优质的模板集合

立即查看 了解详情
Copyright © 2024 Pbootcms模板网 All rights reserved. 陕ICP备19008415号-9 SITEMAP