
第一步,打开 /include/extend.func.php 在最下面加入下面代码
/**
* 文章内容提取图片(多张)自定义输出
*
* @access public
* @param string $string 文档内容
* @param string $num 输出几张
* @return string
*/
if(!function_exists('getBodypics')){
function getBodypics($string, $num){
preg_match_all("/<img([^>]*)s*src=('|")([^'"]+)('|")/",$string,$matches);
$imgsrc_arr = array_unique($matches[3]);
$count = count($imgsrc_arr);
$i = 0;
foreach($imgsrc_arr as $imgsrc){
if($i == $num) break;
$result .= "<img src="$imgsrc"/>";
$i++;
}
return $result;
}
}
第二步,首页/列表页标签调用
{dede:arclist typeid='' row='' channelid='填模型id' addfields='body'}
[field:body function=getBodypics(@me,3)/]
{/dede:arclist}
附加,内容页标签调用
{dede:field.body function=getBodypics(@me,3)/}
标签: 织梦cms
上面是“织梦cms首页从用文章中直接获取显示多张图片显示”的全面内容,想了解更多关于 织梦cms 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_1978.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

php语法如何将值转为整数型
你知道关键词优化的三个技巧吗?