인기글에 이미지(썸네일) 가져오기 도와주세요

인기글에 이미지(썸네일) 가져오기 도와주세요

QA

인기글에 이미지(썸네일) 가져오기 도와주세요

본문

인기글 출력 소스에서 이미지(썸네일) 까지 가져오려면 어떻게 해야하나요?

아무리해도 이미지는 NO IMAGE 라고만 뜨네요.

 

/lib/latest_popular_lib.php 파일 

 

인기글 소스에 썸네일 가져오는 소스를 추가했는데요

추가된 소스는 붉게 표시했습니다.

누가 좀 보시고 알려주십시오 이거 가지고 벌써 며칠째 하고 있는데 이제는 짜증이나네요.

 

 

<?php

if (!defined('_GNUBOARD_')) exit;

 

 

 

 

// 썸네일

include_once(G5_LIB_PATH.'/thumbnail.lib.php');

 

$thumb_width = 250;

$thumb_height = 160; //표시할 이미지의 세로사이즈

 

// 인기글 추출

// $cache_time 캐시 갱신시간

function latest_popular($bo_table, $rows=5, $subject_len=5, $term='', $options='')

{

  //  global $g5; 아래걸로 수정

  global $g5,$thumb_width,$thumb_height; 

 

 

 

switch($term){

case '일간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*30); break;

case '주간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*7); break;

case '월간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*30); break;

}

 

        $list = array();

 

     if($bo_table){ //각 게시판 출력

$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";

        $board = sql_fetch($sql);

        $bo_subject = get_text($board['bo_subject']);

 

        $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름

$sql_between = " wr_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";

        $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 and {$sql_between} order by {$options} limit 0, {$rows} ";

        $result = sql_query($sql);

        for ($i=0; $row = sql_fetch_array($result); $i++) {

            $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);

        }

    }else{ //전체 게시판 출력

 

       $sql_between = " a.bn_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";

       $sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b where a.bo_table = b.bo_table and b.bo_use_search = 1 and a.wr_id = a.wr_parent and {$sql_between} ";

       $sql_order = " order by a.bn_datetime desc ";

 

       $sql = " select a.*, count(b.bo_subject) as cnt {$sql_common} {$sql_order} limit 0, {$rows} ";

       $row = sql_fetch($sql);

  

 

       if($row[cnt] > 0){

$sql = " select a.*, b.bo_subject {$sql_common} {$sql_order} limit 0, {$rows} ";

      $result = sql_query($sql);

      for ($i=0; $row = sql_fetch_array($result); $i++){

$tmp_write_table = $g5['write_prefix'].$row['bo_table'];

$bo_table = $row['bo_table'];

if($i > 0)

$sql2 .= " union ";

$sql2 .= "(select '{$bo_table}' as bo_table, wr_id, wr_subject, wr_hit, wr_good from {$tmp_write_table} where wr_datetime between '{$term_time}' and '".G5_TIME_YMDHIS."') ";

      }

$sql2 .= " order by ".$options." limit 0, 10";

$result2 = sql_query($sql2);

for ($i=0; $row2 = sql_fetch_array($result2); $i++){

   $list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row2['bo_table'].'&wr_id='.$row2['wr_id'];

   $list[$i]['subject'] = $row2['wr_subject'];

}

  }

 

    }

 

    ob_start();

?>

 

<style type=text/css>

.lt_full {position:relative;float:left;padding-bottom:5px;width:100%;height:18px;border:0px solid #e9e9e9}

.lt2 {position:relative;float:left;padding-bottom:5px;width:190px;}

.lt2 ul {margin:0 0 0 0;padding:0;list-style:none}

.lt2 li {padding:0;}

</style>

 

<div class="lt_full">

<div class="lt2">

    <ul>

    <?php for ($i=0; $i<count($list); $i++) {  ?>

        <li>

        

  <!-- 이미지 썸네일 -->      

        <div class="img">

<a href="<?php echo $list[$i]['href'] ?>">

<?php                

 

$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $thumb_width, $thumb_height);

           

if($thumb['src']) {

$img_content = '<img class="img_left" src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';

} else {

$img_content = 'NO IMAGE';

}                

echo $img_content;               

?>

</a>

        

   <!-- 이미지 썸네일 -->       

        

        

        

        

            <?php

            echo "<a href=\"".$list[$i]['href']."\">";

echo "<img src='".G5_URL."/img/num_".($i+1).".gif'> ";

              //  echo "<strong>".$list[$i]['subject']."</strong>";

 

 echo conv_subject($list[$i]['subject'], 17, "…");

 

 

 

          //  if ($list[$i]['comment_cnt'])

            //    echo $list[$i]['comment_cnt'];

 

            echo "</a>";

             ?>

        </li>

    <?php

if (($i+1)%($rows/10)==0) echo "</ul></div><div class='lt2'><ul>";

}

?>

    <?php if (count($list) == 0) { //게시물이 없을 때  ?>

    <li>게시물이 없습니다.</li>

    <?php }  ?>

    </ul>

</div>

</div>

 

<?

$content = ob_get_contents();

    ob_end_clean();

 

    return $content;

}

?>

 

 

<style>

.tab_list ul{position:relative;margin:0;padding:0;border:0px solid #ccc;font-family:Tahoma, Sans-serif;font-size:12px;list-style:none;*zoom:1}

.tab_list ul:after{display:block;clear:both;content:""}

.tab_list li{float:left;margin-bottom:-1px}

.tab_list li a{float:left;position:relative;border:0px solid #eee;border-bottom-color:#ccc;background:#fafafa;color:#666;text-decoration:none}

.tab_list li a span{display:inline-block;padding:6px 15px 6px 25px;letter-spacing:-1px;cursor:pointer}

.tab_list li ul{display:none;position:absolute;top:35px;left:0;width:100%;margin:0;padding:0px 0 0 0;border:0;list-style:none;*zoom:1}

.tab_list li li{float:none;position:relative;border:0px solid #eee;margin:0 0 0 0;padding:0;color:#999}

.tab_list li li a{float:none;margin:0;padding:0;border:0 !important;background:transparent;font-weight:normal;color:#333 !important;letter-spacing:normal;}

.tab_list.m1 .m1 a,

.tab_list.m2 .m2 a,

.tab_list.m3 .m3 a,

.tab_list.m4 .m4 a,

.tab_list.m5 .m5 a {margin-top:-1px;border:0px solid #ccc;border-bottom:0px solid #fff;background:transparent;color:#333;}

.tab_list.m1 .m1 a span,

.tab_list.m2 .m2 a span,

.tab_list.m3 .m3 a span,

.tab_list.m4 .m4 a span,

.tab_list.m5 .m5 a span{padding-top:7px;font-weight:bold}

.tab_list.m1 .m1 ul,

.tab_list.m2 .m2 ul,

.tab_list.m3 .m3 ul,

.tab_list.m4 .m4 ul,

.tab_list.m5 .m5 ul{margin-top:-20px;display:block}

 

 

 

 

 

/* 게시판 목록 */

#bo_cate h2 {width:1px;height:1px;font-size:0;line-height:0;overflow:hidden}

#bo_cate ul {margin-bottom:10px;padding-left:1px;zoom:1}

#bo_cate ul:after {display:block;visibility:hidden;clear:both;content:""}

#bo_cate li {float:left;margin-bottom:-1px}

#bo_cate a {display:block;position:relative;margin-left:-1px;padding:6px 0 5px;width:90px;border:1px solid #ddd;background:#f7f7f7;color:#888;text-align:center;letter-spacing:-0.1em;line-height:1.2em;cursor:pointer}

#bo_cate a:focus, #bo_cate a:hover, #bo_cate a:active {text-decoration:none}

#bo_cate #bo_cate_on {z-index:2;border:1px solid #565e60;background:#fff;color:#565e60;font-weight:bold}

 

 

 

 

 

</style>

 

<div class="tab_list m1">

<ul>

 

 

<li class="m1">

타이틀

<ul>

  <li>

  

  

 

  

  

<?php echo latest_popular($bo_table, 20, 10, '일간', 'wr_hit desc'); ?></li>

</ul>

</li>

 

 

 

</ul>

</div>

 

<script type="text/javascript">

jQuery(function($){

var tab = $('.tab_list');

tab.removeClass('js_off');

tab.css('height', tab.find('>ul>li>ul:visible').height()+40);

function onSelectTab(){

var t = $(this);

var myClass = t.parent('li').attr('class');

t.parents('.tab_list:first').attr('class', 'tab_list '+myClass);

tab.css('height', t.next('ul').height()+40);

}

tab.find('>ul>li>a').click(onSelectTab).focus(onSelectTab);

});

</script>

 

<div style='height:15px;'></div>

이 질문에 댓글 쓰기 :

답변 5

아...bo_table 값을 안주고 전체로 뽑을때 문제가 있네요.....

$list[$i]['bo_table'] = $row2['bo_table']; 

아래 쪽에

$list[$i]['wr_id'] = $row2['wr_id']; 

추가해 주세요.

 

요런 에러에서 문제 찾는 방법은, 함수에 필요한 변수들이 정확하게 입력이 되고 있는지 부터 확인하는게 좋습니다.

그 다음으로는 함수내 쿼리문을 통해 나온 결과값이 정상적으로 들어가 있는지.등등..

 

 

$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);

=>

$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);

$list[$i]['bo_table'] = $bo_table;

 

 

$list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row2['bo_table'].'&wr_id='.$row2['wr_id'];

$list[$i]['subject'] = $row2['wr_subject'];

=>

$list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row2['bo_table'].'&wr_id='.$row2['wr_id'];

$list[$i]['subject'] = $row2['wr_subject'];

$list[$i]['bo_table'] = $row2['bo_table'];

흠...이상해서 테스트해보니 저는 정상적으로 이미지가 나오고 있습니다.

다른 이유가 있는 듯 한데요, 첨부파일로 이미지 올리고 우선적으로 테스트해보세요.

 

혹시 /lib/latest_popular_lib.php  위 소스 파일 위치가 여기고...

index.php 파일(/theme/basic/index.php)에서
<div>
<?php include_once(G5_LIB_PATH.'/latest_popular.lib.php'); ?>
</div>
이렇게 가져오셨나요?

첨부파일이 아니라 에디터로 사진 올려서 그랬나 싶어 다시 첨부파일로 올려도
똑같이 NO IMAGE 만 뜨네요.

정상적으로 이미지가 나온다고하시니 뭘 어떻게 해야할지 더 갑갑해지네요..

if($thumb['src']) {
$img_content = '<img class="img_left" src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
} else {
$img_content = 'NO IMAGE';
}               
echo $img_content;


$thumb['src'] 에 링크가 안되는것 같습니다. NO IMAGE 부분 대신 해당 소스를 넣어보면 "" 이렇게 밖에 표기가 안되네요.

답변을 작성하시기 전에 로그인 해주세요.
전체 129,672 | RSS
QA 내용 검색

회원로그인

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