-
영카트 상품 이미지 모두 가져오기 get_it_image_array그누보드 2020. 9. 3. 10:21
function get_it_image_array($it_id, $width, $height=0, $anchor=false, $img_id='', $img_alt='', $is_crop=false)
{
global $g5;
$aryImg = array();
if(!$it_id || !$width)
{
return '';
}
$sql = " select it_id, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10 from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";
$row = sql_fetch($sql);
if(!$row['it_id'])
{
return '';
}
for($i=1;$i<=10; $i++)
{
$file = G5_DATA_PATH.'/item/'.$row['it_img'.$i];
if(is_file($file) && $row['it_img'.$i])
{
$size = @getimagesize($file);
if($size[2] < 1 || $size[2] > 3)
{
continue;
}
$filename = basename($file);
$filepath = dirname($file);
$img_width = $size[0];
$img_height = $size[1];
}
if($img_width && !$height) {
$height = round(($width * $img_height) / $img_width);
}
if($filename) {
//thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop=false, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3')
$thumb = thumbnail($filename, $filepath, $filepath, $width, $height, false, $is_crop, 'center', false, $um_value='80/0.5/3');
}
if($thumb) {
$file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb);
$img = '<img src="'.$file_url.'" width="'.$width.'" height="'.$height.'" alt="'.$img_alt.'"';
} else {
$img = '<img src="'.G5_SHOP_URL.'/img/no_image.gif" width="'.$width.'"';
if($height)
$img .= ' height="'.$height.'"';
$img .= ' alt="'.$img_alt.'"';
}
if($img_id)
{
$img .= ' id="'.$img_id.'"';
}
$img .= '>';
if($anchor)
{
$img = '<a href="'.G5_SHOP_URL.'/item.php?it_id='.$it_id.'">'.$img.'</a>';
}
$aryImg[] = $img;
}
return $aryImg;
}
//사용법
$aryImg = get_it_image_array($row['it_id'], $this->img_width, $this->img_height, '', '', stripslashes($row['it_name']));
echo "<div class='flexslider2' >";
echo "<ul class='slides'>";
foreach($aryImg as $key => $val)
{
echo "<li class='imgLi'>{$val}</li>";
}
echo "</ul>";
echo "</div>";
'그누보드' 카테고리의 다른 글
영카트 결제 모듈 연동시 세션이 끊어지는 경우 (크롬80보안이슈) 패치 (0) 2021.01.25 스마트에디터 퀵이미지크기 적용 플러그인 (0) 2020.09.03 영카트 상품상세페이지 예약일 옵션에 추가 (2) 2020.09.03 그누보드 주소적용 (0) 2020.06.09 스마트에디터 minWeight 수정방법 (0) 2020.06.01