云企logo

云企分享专用缩略图

DedeCMS文章内容图片自动添加alt标签

更新日期:2022-06-17  

文章内容页文章内容标签

{dede:field.body/}

改成

{dede:field.body runphp=yes}
global $dsql,$id,$aid;
$myid = isset($id) ? $id : $aid;
$row = $dsql->GetOne("SELECT title FROM `dede_archives` WHERE id=$myid");
$title = $row['title'];
$str = @me;
$search = '/(<img.*?)alt=(["'])?.*?(?(2)|s)([^>]+>)/is';
$search1 = '/(<img.*?)title=(["'])?.*?(?(2)|s)([^>]+>)/is';
$content = preg_replace($search,'$1$3',$str);
$content = preg_replace($search1,'$1$3',$content);
@me = str_replace('<img', "<img alt='{$title}' title='{$title}'", $content);
{/dede:field.body}

 

上一篇:WordPress怎么安装? WordPress安装教程

下一篇:dedecms“更新系统缓存”清理沉积缓存的功能
首页
电话咨询