dede织梦获取文章里第一张图片

dede织梦获取文章里第一张图片,第1张

dede织梦获取文章里第一张图片 1、在include/helpers/archive.helper.php 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('//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)"/}      

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/3005944.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-27
下一篇 2022-09-27

发表评论

登录后才能评论

评论列表(0条)

保存