최신글 두번째 첨부이미지 출력

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
최신글 두번째 첨부이미지 출력

QA

최신글 두번째 첨부이미지 출력

본문

안녕하세요

 

최신글에 첫번째와 두번째 첨부이미지를 출력하려고 합니다.

관련된 글이 많이 있어서 금방 해결할 수 있을 줄 알았는데 뭐가 잘못된건지 잘 안되네요 ㅠㅠ

 


<?
.
.
.
for ($i=0; $i<count($list); $i++) {
    $thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $options['thumb_w'], $options['thumb_h'], false, true);
    if($thumb['src']) {
        $img = $thumb['src'];
    } else {
        $img = G5_IMG_URL.'/no_img.png';
    }
    $img_content = '<img src="'.$img.'" alt="'.$thumb['alt'].'">';
.
.
.
?>
 
<?=$img_content?>

 

이렇게 특별할 것 없이 해서 첫번째 첨부이미지만 메인에 노출 되고 있습니다..

두번째 이미지를 함께 노출 하려면 어떻게 해야 할까요?

 

도움 부탁드립니다.

감사합니다.

이 질문에 댓글 쓰기 :

답변 2

아래 함수는 thumbnail.lib.php 같은데 추가해주시고



function bf_no_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $bf_no=0,$is_create=false, $is_crop=false,  $crop_mode='center', $is_sharpen=false, $um_value='80/0.5/3')
{
    global $g5, $config;
    $filename = $alt = $data_path = '';
    $edt = false;

    $row = get_board_file_db($bo_table, $wr_id, 'bf_file, bf_content', "and bf_no = '{$bf_no}' and bf_type in (1, 2, 3, 18) ", true);

    $empty_array = array('src'=>'', 'ori'=>'', 'alt'=>'');

    if(isset($row['bf_file']) && $row['bf_file']) {
        $filename = $row['bf_file'];
        $filepath = G5_DATA_PATH.'/file/'.$bo_table;
        $alt = get_text($row['bf_content']);
    }

    if(!$filename)
        return $empty_array;

    if( $thumbnail_info = run_replace('get_list_thumbnail_info', array(), array('bo_table'=>$bo_table, 'wr_id'=>$wr_id, 'data_path'=>$data_path, 'edt'=>$edt, 'filename'=>$filename, 'filepath'=>$filepath, 'thumb_width'=>$thumb_width, 'thumb_height'=>$thumb_height, 'is_create'=>$is_create, 'is_crop'=>$is_crop, 'crop_mode'=>$crop_mode, 'is_sharpen'=>$is_sharpen, 'um_value'=>$um_value)) ){
        return $thumbnail_info;
    }

    $tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);

    if($tname) {
        if($edt) {
            // 오리지날 이미지
            $ori = G5_URL.$data_path;
            // 썸네일 이미지
            $src = G5_URL.str_replace($filename, $tname, $data_path);
        } else {
            $ori = G5_DATA_URL.'/file/'.$bo_table.'/'.$filename;
            $src = G5_DATA_URL.'/file/'.$bo_table.'/'.$tname;
        }
    } else {
        return $empty_array;
    }

    $thumb = array("src"=>$src, "ori"=>$ori, "alt"=>$alt);

    return $thumb;
}

 

 

아래코드는 for문안에 넣어주세요


$thumb2 = bf_no_thumbnail($bo_table, $list[$i]['wr_id'], $options['thumb_w'], $options['thumb_h'],1, false, true);

 if($thumb2 ['src']) {
        $img = $thumb2 ['src'];
    } else {
        $img = G5_IMG_URL.'/no_img.png';
    }
    $img_content2 = '<img src="'.$img.'" alt="'.$thumb2 ['alt'].'">';


function get_list_thumbnail2($bo_table, $wr_id, $thumb_width, $thumb_height, $is_create=false, $is_crop=false, $crop_mode='center', $is_sharpen=false, $um_value='80/0.5/3')
{
    global $g5, $config;
    $filename = $alt = $data_path = '';
    $edt = false;
    $sql = " select bf_file, bf_content from {$g5['board_file_table']}
                where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_type between '1' and '3' order by bf_no limit 1, 1 ";
    $row = sql_fetch($sql);
    $empty_array = array('src'=>'', 'ori'=>'', 'alt'=>'');
    if(isset($row['bf_file']) && $row['bf_file']) {
        $filename = $row['bf_file'];
        $filepath = G5_DATA_PATH.'/file/'.$bo_table;
        $alt = get_text($row['bf_content']);
    } else {
        $write = get_thumbnail_find_cache($bo_table, $wr_id, 'content');
        $edt = true;
        
        if( $matches = get_editor_image($write['wr_content'], false) ){
            for($i=0; $i<count($matches[1]); $i++)
            {
                // 이미지 path 구함
                $p = parse_url($matches[1][$i]);
                if(strpos($p['path'], '/'.G5_DATA_DIR.'/') != 0)
                    $data_path = preg_replace('/^\/.*\/'.G5_DATA_DIR.'/', '/'.G5_DATA_DIR, $p['path']);
                else
                    $data_path = $p['path'];
                $srcfile = G5_PATH.$data_path;
                if(preg_match("/\.({$config['cf_image_extension']})$/i", $srcfile) && is_file($srcfile)) {
                    $size = @getimagesize($srcfile);
                    if(empty($size))
                        continue;
                    $filename = basename($srcfile);
                    $filepath = dirname($srcfile);
                    preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matches[0][$i], $malt);
                    $alt = isset($malt[1]) ? get_text($malt[1]) : '';
                    break;
                }
                $filename = run_replace('get_editor_filename', $filename, $p);
            }   //end for
        }   //end if
    }
    if(!$filename)
        return $empty_array;
    
    if( $thumbnail_info = run_replace('get_list_thumbnail_info', array(), array('bo_table'=>$bo_table, 'wr_id'=>$wr_id, 'data_path'=>$data_path, 'edt'=>$edt, 'filename'=>$filename, 'filepath'=>$filepath, 'thumb_width'=>$thumb_width, 'thumb_height'=>$thumb_height, 'is_create'=>$is_create, 'is_crop'=>$is_crop, 'crop_mode'=>$crop_mode, 'is_sharpen'=>$is_sharpen, 'um_value'=>$um_value)) ){
        return $thumbnail_info;
    }
    $tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
    if($tname) {
        if($edt) {
            // 오리지날 이미지
            $ori = G5_URL.$data_path;
            // 썸네일 이미지
            $src = G5_URL.str_replace($filename, $tname, $data_path);
        } else {
            $ori = G5_DATA_URL.'/file/'.$bo_table.'/'.$filename;
            $src = G5_DATA_URL.'/file/'.$bo_table.'/'.$tname;
        }
    } else {
        return $empty_array;
    }
    $thumb = array("src"=>$src, "ori"=>$ori, "alt"=>$alt);
    return $thumb;
}

을 추가하신후에

    $thumb = get_list_thumbnail2($bo_table, $list[$i]['wr_id'], $options['thumb_w'], $options['thumb_h'], false, true);

로 바꾸시면 됩니다.

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

회원로그인

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