本站资源均来自互联网,仅供学习与参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
Copyright @ 2015-2020 织梦园 版权所有
Power by DedeCms
鲁ICP备15039853号-1
鲁公网安备 37132302000249号
模板标签 TAG标签 网站地图 XML地图 今日更新 返回顶部
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 `dede_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')/]
如要直接调用用:
{dede:field name='litpic' function="firstimg(@me)"/}