1、在include/helpers/archive.helper.php
/**
* 获得某文档的第一个图片
*
* @param int $aid 文档id
* @return string
*/
if( ! function_exists('GetImgs'))
{
function GetImgs($aid)
{
global $dsql;
$query = "select body FROM `wmd_addonarticle` where aid='$aid'";
$dsql->Execute('body',$query);
$row = $dsql->GetArray('body');
preg_match('/<img(.*)>/i',$row['body'],$str);
$GImgs = $str[0];
//echo $GImgs;
return $GImgs;
}
}
模板里调用
[field:id function=GetImgs(@me)/]
2、include/extend.func.php
//取第一张图地址
function firstimg($str_pic)
{
$str_sub=substr($str_pic,0,-7).".jpg";//删除缩略图字符串最后七位,然后再补上后缀.jpg
return $str_sub;
}
然后在模板里循环调用:
[field:litpic function=firstimg('@me')/]
如要直接调用用:
{wmd:field name='litpic' function="firstimg(@me)"/}
The End



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