해피정

본문에서 여러개 첨부 이미지를 한번에 모두 보기

skin_img.jpg
첨부된 이미지를 한눈에 볼수 있습니다.
 
기능...
1. 작은이미지에 마우스를 이동하면 아래쪽에 큰 이미지가 보입니다.
2. 작은 이미지를 클릭하면 새창에서 이미지가 보입니다.
 
 
viw.skin.php 에서 아래 내용을 
        <?
        // 파일 출력
        for ($i=0; $i<=count($view[file]); $i++) {
            if ($view[file][$i][view])
                echo $view[file][$i][view] . "<p>";
        }
        ?>
 
 
다음과 같이 교체합니다.
 
 
<SCRIPT LANGUAGE='JavaScript'>
<!--
// 이미지뷰어
var win= null;
function View_Open(img, w, h) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/3;
  var settings  ='height='+h+',';
    settings +='width='+w+',';
    settings +='top='+wint+',';
    settings +='left='+winl+',';
    settings +='scrollbars=yes,';
    settings +='resizable=yes,';
    settings +='status=no';
 
  win=window.open("","newWindow",settings);
  win.document.open();
  win.document.write ("<html><head><title>원본 이미지 보기</title></head>");
  win.document.write ("<script>function init(){window.resizeBy(document.all.pop_img.width-document.body.clientWidth, document.all.pop_img.height-document.body.clientHeight+10);}</script>");
  win.document.write ("<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 oncontextmenu='return false' ondragstart='return false' onkeydown='return false' onselectstart='return false' onload='init();'>");
  win.document.write ("<img src='"+img+"' border=0 onclick='window.close();' style='cursor:hand' title='클릭하면 닫혀요' id='pop_img'>");
  win.document.write ("</body></html>");
  win.document.close();
}
 
image_directory = "";   //배경이미지 경로
clear = new Image();  clear.src = image_directory + "./img/blank.gif";
<?
//파일 뽑기
$sql2_hp_view_img = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result2_hp_view_img = sql_query($sql2_hp_view_img);
for ($j=0; $row2_hp_view_img = sql_fetch_array($result2_hp_view_img); $j++) {
  $view_one = "{$g4['path']}/data/file/{$bo_table}/{$row2_hp_view_img['bf_file']}";
?>
  view_img<?=$j?> = new Image();
  view_img<?=$j?>.src = "<?=$g4['path']?>/data/file/<?=$bo_table?>/<?=$row2_hp_view_img['bf_file']?>";
<? } ?>
function bgChange(imgName) {
  document.all.view_img.src = eval(imgName + ".src");
}
//-->
</SCRIPT>
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
  <tr>
    <td style="padding:10 0 20 0;" align="center">
<?
//파일 뽑기
$sql_hp_view_img = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result_hp_view_img = sql_query($sql_hp_view_img);
for ($i=0; $row_hp_view_img = sql_fetch_array($result_hp_view_img); $i++) {
 
  //썸네일 코드 시작
  $data_path = $g4['path'] . "/data/file/{$bo_table}";//라이브러리 파일 참조
  $thumb_path = $data_path . '/thumbOpen';
 
  $view_w = 100; //썸네일 가로사이즈
  $view_h = 75; //썸네일 세로사이즈
  $sch_q = 100; //썸네일 퀼리티
 
  if (!is_dir($thumb_path)) {
    @mkdir($thumb_path, 0707);
    @chmod($thumb_path, 0707);
  }
  $filename = $row_hp_view_img[bf_file]; //파일명
  $thumb = $thumb_path.'/'.$filename; //썸네일
  if (!file_exists($thumb)) {
    $file = $data_path.'/'.$filename; //원본
    if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
      $size = getimagesize($file);
      if ($size[2] == 1)
        $src = imagecreatefromgif($file);
      else if ($size[2] == 2)
        $src = imagecreatefromjpeg($file);
      else if ($size[2] == 3)
        $src = imagecreatefrompng($file);
      else
        continue;
     
      $rate = $view_w / $size[0];
      $height = (int)($size[1] * $rate);
     
      if ($height < $view_h)
        $dst = imagecreatetruecolor($view_w, $height);
      else
        $dst = imagecreatetruecolor($view_w, $view_h);
      imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
      imagejpeg($dst, $thumb_path.'/'.$filename, $sch_q);
      chmod($thumb_path.'/'.$filename, 0707);
    }
  }
 
  if (file_exists($thumb) && $filename) {
?>
    <a href="javascript:void(0);" onClick="View_Open('<?=$data_path?>/<?=$filename?>')" onMouseOver="bgChange('view_img<?=$i?>');" onMouseOut="bgChange('view_img<?=$i?>');"><img src='<?=$thumb?>' border=0 width="69" height="60"></a>
<?
    //onMouseOut="bgChange('clear');"
  }
}
?>
    </td>
  </tr>
  <tr>
    <td align="center" valign="top"><img src="<?=$view_one?>" name="view_img" border="0"></td>
  </tr>
</table>

첨부파일

skin_img.jpg (49.7 KB)
0회 2008-07-03 18:16
|

댓글 6개

소스에서 sql 쿼리 선언문 변경했습니다.
간혹 왼쪽 메뉴, 퀵 메뉴 등에서 sql 쿼리를 선언해서 사용하는것과 중복되어 오류가 나는 경우가 있더군요..
그래서 sql 선언문을 중복되지 않을수 있는 것으로 사용 수정했습니다.
굿 제 홈으로 자료 좀 옮겨갑니다~
오홍 해피정님 멋져요 ~~
엄청큰사진은 게시판 설정에서 잡아준 사이즈로 조절이 안돼는데요 ㅠㅠ
완전 멋진 이미지 view 페이지
좋은 뷰어입니다.
댓글을 작성하시려면 로그인이 필요합니다. 로그인

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
17년 전 조회 2,807
17년 전 조회 3,265
17년 전 조회 3,359
17년 전 조회 2,889
17년 전 조회 3,678
17년 전 조회 1.2만
17년 전 조회 5,181
17년 전 조회 9,070
17년 전 조회 5,905
17년 전 조회 4,573
17년 전 조회 3,350
17년 전 조회 3,573
17년 전 조회 3,878
17년 전 조회 3,078
17년 전 조회 5,386
17년 전 조회 3,404
17년 전 조회 3,374
17년 전 조회 2,869
17년 전 조회 4,567
17년 전 조회 2,442
🐛 버그신고