썸네일 특정 순서만 불러오기

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
썸네일 특정 순서만 불러오기

QA

썸네일 특정 순서만 불러오기

본문


<?php
include_once("./_common.php");
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
$thumb = get_list_thumbnail($board['bo_table'], $write['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true); // 394 281
if($thumb['src']) {
    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
} else {
    $img_content = '<span class="no_image" style="'.$line_height_style.'">no image</span>';
}
?>
 
<div class="item">
        <div class="imgbox">
            <?php echo run_replace('thumb_image_tag', $img_content, $thumb); ?>
        </div>       
</div>

 

안녕하세요 작업중인 게시판에 위처럼 이미지를 불러오고 있는데요 

<?php echo run_replace('thumb_image_tag', $img_content, $thumb); ?>

---> 이렇게 하면 해당 작성글의 이미지를 불러오긴 하는데 

이거를 첫번째 이미지 / 두번째 이미지  이렇게 특정 순서 이미지만 불러오려고 하려면

어떻게 해야하나요...?

이 질문에 댓글 쓰기 :

답변 3



// 게시글리스트 썸네일 생성
function gw_get_list_thumbnail($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', $no)
{
    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 {$no}, 1 ";
    $row = sql_fetch($sql);
    $empty_array = array('src' => '', 'ori' => '', 'alt' => '');

    $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;
}



사용방법

$thumb = gw_get_list_thumbnail($bo_table, $write['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true, 'center', false, '80/0.5/3', '0'); // 마지막 숫자 0을 1,2,3,4,5등으로 변경

$thumb = get_list_thumbnail($board['bo_table'], $write['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true); // 394 281
이 위치에 저 코드를 대체하시면됩니다.

실행은



if($thumb['src']) {
    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
} else {
    $img_content = '<span class="no_image" style="'.$line_height_style.'">no image</span>';
}

여기서 다 배열로 이미지를 만드니까요.

그누위즈님 답변 수정해서 사용하기

gw_get_list_thumbnail<== 이 함수 맨 뒤에 이미지 순번을 파라메터로 넣기가 복잡하니 다음처럼

맨 앞으로 옮겨서 하면 좋겠습니다

function gw_get_list_thumbnail($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', $no)
==>

function gw_get_list_thumbnail($no=0 ,$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')

 

사용시 ( 3번째 이미지 썸네일 )

$thumb =gw_get_list_thumbnail( 2, $board['bo_table'], $write['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']); 

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

회원로그인

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