phpcms v9 调用自定义字段多图片的第一张或第N张图为缩略图
时间:2023年06月16日
/来源:网络
/编辑:佚名
1.打开相应要使用组图的模型的组图字段,添加组图 字段提示为
<div class="content_attr">
<label><input type='checkbox' name='auto_thumbp' value="1" checked>是否获取内容第</label><input type="text" name="auto_thumb_nop" value="1" size="2" class="">张图片作为标题图片
</div>
2.打开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_thumbp']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
$自定义字段名 = $自定义字段名 ? $自定义字段名 : stripslashes($modelinfo['自定义字段名']);
$auto_thumb_no = intval($_POST['auto_thumb_nop'])-1;
if(preg_match_all("/(=>)\s([\b\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $自定义字段名, $matches)) {
$systeminfo['thumb'] = $matches[3][$auto_thumb_no];
}
}
复制代码
注意:content_model.class.php文件有两片需要添加这个代码,一处是新增加文章的时候,一处是修改文章的时候!
<div class="content_attr">
<label><input type='checkbox' name='auto_thumbp' value="1" checked>是否获取内容第</label><input type="text" name="auto_thumb_nop" value="1" size="2" class="">张图片作为标题图片
</div>
2.打开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_thumbp']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
$自定义字段名 = $自定义字段名 ? $自定义字段名 : stripslashes($modelinfo['自定义字段名']);
$auto_thumb_no = intval($_POST['auto_thumb_nop'])-1;
if(preg_match_all("/(=>)\s([\b\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $自定义字段名, $matches)) {
$systeminfo['thumb'] = $matches[3][$auto_thumb_no];
}
}
复制代码
注意:content_model.class.php文件有两片需要添加这个代码,一处是新增加文章的时候,一处是修改文章的时候!
新闻资讯 更多
- 【建站知识】查询nginx日志状态码大于400的请求并打印整行04-03
- 【建站知识】Python中的logger和handler到底是个什么?04-03
- 【建站知识】python3拉勾网爬虫之(您操作太频繁,请稍后访问)04-03
- 【建站知识】xpath 获取meta里的keywords及description的方法04-03
- 【建站知识】python向上取整以50为界04-03
- 【建站知识】scrapy xpath遇见乱码解决04-03
- 【建站知识】scrapy爬取后中文乱码,解决word转为html 时cp1252编码问题04-03
- 【建站知识】scrapy采集—爬取中文乱码,gb2312转为utf-804-03