调用内容图片小图,简单粗暴 功能增强

别跟路人甲BB 15天前 585

<!--图片-->
<dl class="row small">
    <dt>
    <?php 
    $post = post_read($_thread['firstpid']);
    $content =($post['message']);
    $message = strip_tags($content);
    $pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
    $imgcount=preg_match_all($pattern,$content,$match);
    $imgs=array();
    for($i=0;$i<3;$i++){    //此处要调用几张将数字改成调用张数即可,默认3张
        if(!empty($match[0][$i])){
            $imgs[$i]=$match[1][$i];
        }
    }
    ?>                                  
    <?php if($imgcount > 0) { ?>
    <div class="pic">
    <?php foreach($imgs as $pic){?>
    <img height="90" src="<?php echo $pic ?>">                           
    <?php }?>
    <?php if($imgcount > 3) { ?>    //此处的数量是为了输出一共几张而用
    <span>  共<?php echo $imgcount;?>张</span>
    <?php }?>
    </div>
    <?php } ?>
    </dt>
    </dl>

默认主题的话打开:view/htm/thread_list.inc.htm 

复制以上代码到<!--{hook thread_list_inc_filetype_icon_after.htm}-->这个钩子下面

效果图:



最新回复 (14)
返回
发新帖
HTTP/1.1 502 Bad Gateway Content-Type: text/html Connection: close Content-Length: 308 Date: Sat, 24 Feb 2018 05:58:54 GMT X-Via: 1.1 localhost.localdomain (random:600187 Fikker/Webcache/3.7.4) 502 Bad Gateway

502 Bad Gateway - Cann't Connect To Upstream Server By SSL Read

Server: localhost.localdomain
Date: 2018-02-24 05:58:54

Fikker/Webcache/3.7.4