PbootCMS缩略图及轮播多图添加自动取内容图选择按钮

发布期:2023-08-31 | 来源处:本站 | 编辑者:超级管理员 | 浏览量:0
31
08
2023


有些公司的网站前端不需要缩略图,只需要个别文章显示缩略图,PbootCMS默认自动提取文章里的图片作为缩略图。设置可以增加一个选择按钮,判断下就可以。

最终实现效果如下:

PbootCMS缩略图及轮播多图添加自动取内容图选择按钮



找到文件 apps /admin /view /default /content /content.html (大约在代码340行和740行,添加以下代码)

<div class="layui-form-item">
<label class="layui-form-label">内容图片设置</label>
<div class="layui-input-block">
<input type="checkbox" name="contenttopic" value="1" title="内容首图设置缩略图">
<input type="checkbox" name="contenttopics" value="1" title="内容图片设置多图">
</div>
</div>


找到文件 apps /admin /controller /content /ContentController.php 

(大约在代码96和428行)

$contenttopic = post('contenttopic');//设置内容首图按钮
$contenttopics = post('contenttopics');//设置内容图片为多图按钮


大约在代码136和468行处添加)

// 提取文章第一张图为缩略图
if ($contenttopic && preg_match('/<imgs+.*?src=s?['|"](.*?(.gif|.jpg|.png|.jpeg))['|"].*?[/]?>/i', decode_string($content), $srcs) && isset($srcs[1])) {
    $ico = $srcs[1];
}

// 设置内容图片为多图,不适用内容图片很多的情况下使用。
if ($contenttopics && preg_match_all('/<imgs+.*?src=s?['|"](.*?(.gif|.jpg|.png|.jpeg))['|"].*?[/]?>/i', decode_string($content), $srcs)) {
    $strsrcs = implode(",", $srcs[1]);
    $pics = $strsrcs;
}


附说明:要么复盖下面这段原代码,要么删除这段原代码,才能起作用。

// 无缩略图时,自动提取文章第一张图为缩略图
if (! $ico && preg_match('/<imgs+.*?src=s?['|"](.*?(.gif|.jpg|.png|.jpeg))['|"].*?[/]?>/i', decode_string($content), $srcs) && isset($srcs[1])) {
$ico = $srcs[1];
 }




TAG 标签:

网站优化专区

本月热点资讯
热线(微信同号):
137-6042-7131
在线客服:
售前
售前
售前
售后
微信图标
联系微信:
微信联系二维码
Hi,Are you ready?
准备好开始了吗?
那就与我们取得联系吧

咨询送礼现在提交,将获得全宝鑫公司策划专家免费为您设计
创意LOGO,免费设计您满意的名片。
下单送礼感恩多年,新老用户下单即送创业型空间+域名等大礼
8:30-18:00小时免费咨询热线137-6042-7131
建站留言合作意向表

您需要的服务

您关注的地方

您大概的预算

直接咨询