打开/include/extend.func.php文件
在最下面加入:
//文章body优化替换
function replaceurl($newurl)
{
global $dsql,$id;
//获取图片附加表imgurls字段内容进行处
$row = $dsql->GetOne("SELECT title FROM wmd_archives where id=$id");
//替换图片Alt为文档标题
$newurl=str_ireplace(array('alt=""','alt=\'\''),'',$newurl);
$newurl=preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU"," ",$newurl);
$newurl=str_ireplace("<img " ,"<img alt=\"".$row['title']."\"",$newurl);
//去掉结尾空格
$newurl=str_ireplace(" /","/",$newurl);
$newurl=str_ireplace(" />","/>",$newurl);
return $newurl;
}
前端调用代码:
{wmd:field.body function='replaceurl(@me)'/}
需要图片中的style width height属性就把上面代码修改成下面的代码
//文章body优化替换
function replaceurl($newurl)
{
global $dsql,$id;
//获取图片附加表imgurls字段内容进行处
$row = $dsql->GetOne("SELECT title FROM wmd_archives where id=$id");
//去掉img的width和height
$newurl=preg_replace('/style=\"width\:(.*)\"/','',$newurl);
//替换图片Alt为文档标题
$newurl=str_ireplace(array('alt=""','alt=\'\''),'',$newurl);
$newurl=preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU"," ",$newurl);
$newurl=str_ireplace("<img " ,"<img alt=\"".$row['title']."\"",$newurl);
//去掉结尾空格
$newurl=str_ireplace(" /","/",$newurl);
$newurl=str_ireplace(" />","/>",$newurl);
return $newurl;
}
The End



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)