이용후기 이미지를 선택하고 싶습니다.

이용후기 이미지를 선택하고 싶습니다.

QA

이용후기 이미지를 선택하고 싶습니다.

본문

안녕하세요.

 

영카트의 이용후기를 작성하면 기본적으로 

상품의 첫번째 이미지를 썸네일로 만들어서 보여주고 있습니다.

 

이것을 두번째 이미지로 바꾸고 싶습니다.

모든 상품에는 3개 이상의 이미지가 첨부되어 있는데

이중에 꼭 2번째 첨부된 이미지를 이용후기에서는 보여주려고 합니다.

 

/lib/shop.lib.php 를 보니 아래와 같은 함수가 있는데

이것을 어떻게 바꾸면 될까요?

 

고수분들의 도움을 부탁드립니다.

 


// 사용후기 썸네일 생성
function get_itemuselist_thumbnail($it_id, $contents, $thumb_width, $thumb_height, $is_create=false, $is_crop=true, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3')
{
    global $g5, $config;
    $img = $filename = $alt = "";
    if($contents) {
        $matches = get_editor_image($contents, 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 = get_text($malt[1]);
                break;
            }
        }
        if($filename) {
            $thumb = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
            if($thumb) {
                $src = G5_URL.str_replace($filename, $thumb, $data_path);
                $img = '<img src="'.$src.'" width="'.$thumb_width.'" height="'.$thumb_height.'" alt="'.$alt.'">';
            }
        }
    }
    if(!$img)
        $img = get_it_image($it_id, $thumb_width, $thumb_height);
    return $img;
}

이 질문에 댓글 쓰기 :

답변 1

lib/shop.lib.php 를 여시고 

function get_it_image($it_id, $width, $height=0, $anchor=false, $img_id='', $img_alt='', $is_crop=false)

를 찾으시고 

해당 내용을 카피한다음 함수명을 2로 변경합니다  
function get_it_image2($it_id, $width, $height=0, $anchor=false, $img_id='', $img_alt='', $is_crop=false)


get_it_image2 해당 함수 안에  
for($i=1;$i<=10; $i++) {

부분을 2부터 시작합니다 

for($i=2;$i<=10; $i++) {


여기서 2가지 방법이 있습니다 
1. 고객이 올린 이미지 먼저 보여주고 없으면 제품 이미지를 보여주시는 방법과 
2. 무조건 제품이미지를 보여주는 방법 

먼저 1은 해당 
function get_itemuselist_thumbnail($it_id, $contents, $thumb_width, $thumb_height, $is_create=false, $is_crop=true, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3')
함수 안에 아래부분을 

    if(!$img)
        $img = get_it_image($it_id, $thumb_width, $thumb_height);

아래와 같이 get_it_image2 로변경합니다 
    if(!$img)
        $img = get_it_image2($it_id, $thumb_width, $thumb_height);

다음 2번 방법은 
itemuselist.skin.php  안에 

<div class="sps_img">
            <a href="<?php echo $it_href; ?>">
                <?php echo get_itemuselist_thumbnail($row['it_id'], $row['is_content'], 100, 100); ?>
                <span><?php echo $row2['it_name']; ?></span>
            </a>
        </div>

부분을 
<div class="sps_img">
            <a href="<?php echo $it_href; ?>">
                <?php echo get_it_image2($row['it_id'], 100, 100);?>
                <span><?php echo $row2['it_name']; ?></span>
            </a>
        </div>
으로 변경해 주시면 됩니다
 

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

회원로그인

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