首页 > CMS教程 > 帝国CMS    日期:2020-02-13 / 来自互联网 / 浏览

1、在 e/class/userfun.php 里面增加

//替换正文IMG里的ALT内容 functionuser_imgalt($mid,$f,$isadd,$isq,$value,$cs){ $title=$_POST['title']; $htmls=$value; $pattern= "/]+>/"; preg_match_all($pattern, $htmls, $matches); for($i=0; $i<=count($matches[0]); $i++) { preg_match_all("/alt=".+?"/",$matches[0][$i],$altimg); $t_alt=count($altimg[0]); if($t_alt==0){ $htmls=str_replace("<img","<img alt="{$title}"",$htmls); } } return$htmls; }

2、然后在后台系统设置-数据表模型-字段管理里面 编辑 newstext字段

增加如下

user_imgalt

帝国CMS内容关键字替换图片标签

即可,图片上的alt就自动被替换成了文章标题 适合SEO!

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章

1 2 3 4 5