有一些朋友的网站前端不需要缩略图,只需要个别文章显示缩略图,PbootCMS模板默认自动提取文章里的图片作为缩略图。其实可以增加一个按钮,判断下就可以。最终实现效果如下:

找到文件apps\admin\view\default\content\content.html(在代码340行及740行,添加以下代码)
1 2 3 4 5 6 7 |
找到文件apps\admin\controller\content\ContentController.php
在代码96/428行
1$contenttopic = post('contenttopic');//设置内容首图按钮 2$contenttopics = post('contenttopics');//设置内容图片为多图按钮 |
在代码136/468行处添加
01// 提取文章第一张图为缩略图 02if ($contenttopic && preg_match('/<img\s+.*?src=http://www.zgzjw.top/static/image/nopic320.png decode_string($content), $srcs) && isset($srcs[1])) { 03 $ico = $srcs[1]; 04} 05 06// 设置内容图片为多图,不适用内容图片很多的情况 adminbuy.cn 07if ($contenttopics && preg_match_all('/<img\s+.*?src=http://www.zgzjw.top/static/image/nopic320.png decode_string($content), $srcs)) { 08 $strsrcs = implode(",", $srcs[1]); 09 $pics = $strsrcs; 10} |
以上是文章添加的代码,文章修改的代码也是一样
