在使用phpcms制作网站过程中,如果我们需要调用自定义的多图片,让自定义的多图片中上传的指定排行的图片设置为文章默认缩略图,我们该怎样做
首先打开相应的组图模型的组图字段,添加自己设置的组图字段提示:
<div class="content_attr">
<label><input type='checkbox' name='auto_qtoolpic' value="1" checked>获取内容中第</label><input type="text" name="auto_thumb_qtoolpic" value="1" size="2" >张图片设为标题图片
</div>
继续打开phpcms文件夹、model文件夹、content_model.class.php文件找到如下代码:
if(isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
$content = $content ? $content : stripslashes($modelinfo['content']);
$auto_thumb_no = intval($_POST['auto_thumb_no'])-1;
if(preg_match_all("/(src)=([\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
$systeminfo['thumb'] = $matches[3][$auto_thumb_no];
}
}
在代码下方添加如下代码:
if(isset($_POST['auto_qtoolpic']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
字段名 = 字段名 ? 字段名 : stripslashes($modelinfo['字段名']);
$auto_thumb_no = intval($_POST['auto_thumb_qtoolpic'])-1;
if(preg_match_all("/(=>)\s([\b\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", 字段名, $matches)) {
$systeminfo['thumb'] = $matches[3][$auto_thumb_no];
}
}
其中字段名修改为自己设置的字段名称,在文件中有两处需要添加以上的代码.