테스트 사이트 - 개발 중인 베타 버전입니다

썸네일 특정 순서만 불러오기 채택완료

한시오십분 1년 전 조회 5,177

</p>

<p><?php

include_once("./_common.php");

include_once(G5_LIB_PATH.'/thumbnail.lib.php');</p>

<p>$thumb = get_list_thumbnail($board['bo_table'], $write['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true); // 394 281</p>

<p>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>';

}

?></p>

<p> </p>

<p><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개

채택된 답변
+20 포인트
그누위즈

</p>

<pre>
// 게시글리스트 썸네일 생성
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;
}</pre>

<p>


사용방법
</p>

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

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

한시오십분
1년 전
Array 라고만 뜨네요 ㅠㅠ
해당 페이지에 둘 다 작성하는거 맞을까요..?

댓글을 작성하려면 로그인이 필요합니다.

1년 전

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

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']); 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

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

실행은

</p>

<pre>
<code>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>';
}</code></pre>

<p>

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

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인