그룹 최신글 리스트 이미지 질문 드립니다.

그룹 최신글 리스트 이미지 질문 드립니다.

QA

그룹 최신글 리스트 이미지 질문 드립니다.

본문

예전에 2015년정도의 포퓨리 님이 등록해주신 스킨을 보고서 약간식 수정해서 그룹 최신리스트를 해보고 있습니다. 

리스트는 잘 가지고 오는데 이미지를 잘 못가지고 와서요.. ㅠㅠ 

이미지를 가져오는데 도움주시면 감사하겠습니다. 

 

latest.skin.php


<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH . '/thumbnail.lib.php');
$imgwidth = "640"; //표시할 이미지의 가로사이즈
$imgheight = "780"; //표시할 이미지의 세로사이즈
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="' . $latest_skin_url . '/style.css">', 1);
?>
<div class="lt" data-aos="fade-up" data-aos-delay="600">
  <strong class="lt_title"><a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo_table ?>"><?php echo $bo_subject; ?></a></strong>
  <div class="owl-carousel owl-theme latest-carousel">
    <?php for ($i = 0; $i < count($list); $i++) {  ?>
      <div class="a-item">
        <a href="<?= $list[$i]['href'] ?>" class="info">
          <?php
          $thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $imgwidth, $imgheight, false, true);
          $img_content = 'NO IMAGE';
          if ($thumb['src']) {
            $img_content = '<img src="' . $thumb['src'] . '" alt="' . $list[$i]['subject'] . '">';
          }
          echo '<div class="img-box">';
          echo $img_content;
          echo '<div class="bg"></div>';
          echo '</div>';
          ?>
          
          <div class="txt_box clearfix">
            <div class="subject">
              <?php //제목
              if ($list[$i]['is_notice'])
                echo "<strong>" . $list[$i]['subject'] . "</strong>";
              else
                echo $list[$i]['subject'];
              ?>
              <?php //댓글수
              if ($list[$i]['comment_cnt'])
                echo $list[$i]['comment_cnt'];
              ?>
            </div>
            <!--<div class="substance">
              <?php //내용    
              if (!$options['content_length']) $options['content_length'];
              echo cut_str(strip_tags($list[$i]['wr_content']), $options['content_length']);
              ?>
            </div>-->
        </a>
        <input type="button" class="more" value="자세히 보기" onClick="location.href='<?php echo $list[$i]['href'] ?>'">
      </div>
      <?php
      // echo $list[$i]['icon_reply']." ";
      // if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
      // if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }
      //if (isset($list[$i]['icon_new'])) echo " " . $list[$i]['icon_new'];
      //if (isset($list[$i]['icon_hot'])) echo " " . $list[$i]['icon_hot'];
      //if (isset($list[$i]['icon_file'])) echo " " . $list[$i]['icon_file'];
      //if (isset($list[$i]['icon_link'])) echo " " . $list[$i]['icon_link'];
      //if (isset($list[$i]['icon_secret'])) echo " " . $list[$i]['icon_secret'];
      ?>
  </div>
<?php }  ?>
<?php if (count($list) == 0) { //게시물이 없을 때 ?>
  <div>게시물이 없습니다.</div>
<?php }  ?>
</div>
<div class="lt_more"><a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo_table ?>"><span class="sound_only"><?php echo $bo_subject ?></span>더보기</a></div>
</div>
<script>
  $('.latest-carousel').owlCarousel({
    loop: true,
    margin: 30,
    nav: false,
    dots: false,
    navSpeed: 700,
    navText: ['PREV', 'NEXT'],
    autoplay: true,
    autoplayTimeout: 4000,
    smartSpeed: 1000, // 슬라이드 전환 속도 조절
    autoplaySpeed: 1000, // 자동 재생시 슬라이드 전환 속도
    responsive: {
      0: {
        items: 1
      },
      640: {
        items: 2
      },
      1000: {
        items: 3
      },
      1200: {
        items: 4
      },
    }
  })
</script>
<!-- } <?php echo $bo_subject; ?> 최신글 끝 -->

 

라이브러리의 
latest.lib.php


<?php
if (!defined('_GNUBOARD_')) exit;
@include_once(G5_LIB_PATH.'/thumbnail.lib.php');
// 최신글 추출
function latest2($skin_dir='', $gr_id, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
    global $g5;
    //static $css = array();
    if (!$skin_dir) $skin_dir = 'basic';    
    
    if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
        if (G5_IS_MOBILE) {
            $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            if(!is_dir($latest_skin_path))
                $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        } else {
            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        }
        $skin_dir = $match[1];
    } else {
        if(G5_IS_MOBILE) {
            $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
        } else {
            $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;
        }
    }
    $cache_fwrite = false;
    if(G5_USE_CACHE) {
        $cache_file = G5_DATA_PATH."/cache/latest-{$gr_id}-{$skin_dir}-{$rows}-{$subject_len}.php";
        if(!file_exists($cache_file)) {
            $cache_fwrite = true;
        } else {
            if($cache_time > 0) {
                $filetime = filemtime($cache_file);
                if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) {
                    @unlink($cache_file);
                    $cache_fwrite = true;
                }
            }
            if(!$cache_fwrite)
                include($cache_file);
        }
    }
    if(!G5_USE_CACHE || $cache_fwrite) {
        $list = array();
        
        $sql = "select a.*, b.bo_subject, c.gr_subject, c.gr_id from g5_board_new a, g5_board b, g5_group c where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = 1 and c.gr_id = '{$gr_id}' and a.wr_id = a. wr_parent order by a.bn_id desc limit 0, {$rows}";
        $result = sql_query($sql);
        for ($i=0; $row=sql_fetch_array($result); $i++) {
        
            $sql = " select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ";
            $board = sql_fetch($sql);                    
        
            $tmp_write_table = $g5['write_prefix'].$row['bo_table'];
            $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");
            
            $list[$i] = $row2;
            $list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len);
            $list[$i]['subject'] = "[".$row['bo_subject']."] ".$list[$i]['subject'];
            $list[$i]['bo_table'] = $row['bo_table'];
            
            // 썸네일 추가
            if($options && is_string($options)) {
                $options_arr = explode(',', $options);
                $thumb_width = $options_arr[0];
                $thumb_height = $options_arr[1];
                $thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);
                // 이미지 썸네일
                if($thumb['src']) {
                    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
                    $list[$i]['img_thumbnail'] = '<a href="'.$list[$i]['href'].'" class="lt_img">'.$img_content.'</a>';
                // } else {
                //     $img_content = '<img src="'. G5_IMG_URL.'/no_img.png'.'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'" class="no_img">';
                }
            }
            
        }
        if($cache_fwrite) {
            $handle = fopen($cache_file, 'w');
            $cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".$bo_subject."';\n\$list=".var_export($list, true)."?>";
            fwrite($handle, $cache_content);
            fclose($handle);
        }
        
    }
    /*
    // 같은 스킨은 .css 를 한번만 호출한다.
    if (!in_array($skin_dir, $css) && is_file($latest_skin_path.'/style.css')) {
        echo '<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">';
        $css[] = $skin_dir;
    }
    */
    ob_start();
    include $latest_skin_path.'/latest.skin.php';
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
    
}

 

index.php

echo  latest2("theme/group_basic", 'product', 100, 50, 1, $options);

이 질문에 댓글 쓰기 :

답변 1

$thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $imgwidth, $imgheight, false, true);

 

$bo_table이 아니라 $list[$i]['bo_table'] 이 들어가야 할것 같습니다. 근데 lib에 다시 보니 이미 썸네일 로직이 있고

$list[$i]['img_thumbnail']로 있는데 중복 생성인거 같습니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 15,826
QA 내용 검색
filter #php ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT