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

초보라 잘 모르네요.. 채택완료

수아주환 7년 전 조회 3,298

 

 $lis = sql_fetch($sql);    

 echo $lis[bf_file];

?>  

 

이렇게 파일은 불러 왔는데 불러온 이미지를 어떻게 출력하나요..??

 

 echo $lis[bf_file];   <- 이렇게 하니까 숫자만 나오던데 이미지를 출력하려면 어떻게 해야 하나요..??

 

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

답변 5개

채택된 답변
+20 포인트
베원
7년 전

그렇게 sql문을 날리실 필요 없이

</p>

<p>$thumb = get_list_thumbnail("게시판 명", "wr_id", "width", "height");</p>

<p>if($thumb['src']) echo "<img src='".$thumb['src']."'>";</p>

<p>

이렇게 하시면 됩니다.

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

답변에 대한 댓글 1개

수아주환
7년 전
자동으로 비율이 조절되려면 가로 세로를 지정하지 않아야 하는데..
지정값을 %로 줄 수가 없어요..^^;;

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

j
7년 전

베원님 방법 사용하시면 될 것같습니다. 가로 세로를 함수로 불러오기는 하지만 

echo문에서 출력하지 않으니까요 클래스지정하시고 싶으시거나 인라인 css를 지정하시고 싶으시멵  echo 문 출력부분에 추가하시면됩니다 

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

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

lib/common.lib.php

 

// view_file_link() 함수에서 넘겨진 이미지를 보이게 합니다. // {img:0} ... {img:n} 과 같은 형식 function view_image($view, $number, $attribute) {     if ($view['file'][$number]['view'])         return preg_replace("/>$/", " $attribute>", $view['file'][$number]['view']);     else         //return "{".$number."번 이미지 없음}";         return ""; }  

bbs/view.php

 

//$view['rich_content'] = preg_replace("/{이미지\:([0-9]+)[:]?([^}]*)}/ie", "view_image(\$view, '\\1', '\\2')", $view['content']); function conv_rich_content($matches) {     global $view;     return view_image($view, $matches[1], $matches[2]); }

 

skin/board/basic/view.skin.php

 

    \n";

            for ($i=0; $i<=count($view['file']); $i++) {                 if ($view['file'][$i]['view']) {                     //echo $view['file'][$i]['view'];                     echo get_view_thumbnail($view['file'][$i]['view']);                 }             }

            echo "

\n";         }          ?>

 

 

 

lib/thumbnail.lib.php

 

// 게시글보기 썸네일 생성 function get_view_thumbnail($contents, $thumb_width=0) {     global $board, $config;

    if (!$thumb_width)         $thumb_width = $board['bo_image_width'];

    // $contents 중 img 태그 추출     $matches = get_editor_image($contents, true);

    if(empty($matches))         return $contents;

    for($i=0; $i

        $img = $matches[1][$i];         preg_match("/src=[\'\"]?([^>\'\"]+[^>\'\"]+)/i", $img, $m);         $src = $m[1];         preg_match("/style=[\"\']?([^\"\'>]+)/i", $img, $m);         $style = $m[1];         preg_match("/width:\s*(\d+)px/", $style, $m);         $width = $m[1];         preg_match("/height:\s*(\d+)px/", $style, $m);         $height = $m[1];         preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img, $m);         $alt = get_text($m[1]);

        // 이미지 path 구함         $p = parse_url($src);         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(is_file($srcfile)) {             $size = @getimagesize($srcfile);             if(empty($size))                 continue;

            // jpg 이면 exif 체크             if($size[2] == 2 && function_exists('exif_read_data')) {                 $degree = 0;                 $exif = @exif_read_data($srcfile);                 if(!empty($exif['Orientation'])) {                     switch($exif['Orientation']) {                         case 8:                             $degree = 90;                             break;                         case 3:                             $degree = 180;                             break;                         case 6:                             $degree = -90;                             break;                     }

                    // 세로사진의 경우 가로, 세로 값 바꿈                     if($degree == 90 || $degree == -90) {                         $tmp = $size;                         $size[0] = $tmp[1];                         $size[1] = $tmp[0];                     }                 }             }

            // 원본 width가 thumb_width보다 작다면             if($size[0] <= $thumb_width)                 continue;

            // Animated GIF 체크             $is_animated = false;             if($size[2] == 1) {                 $is_animated = is_animated_gif($srcfile);             }

            // 썸네일 높이             $thumb_height = round(($thumb_width * $size[1]) / $size[0]);             $filename = basename($srcfile);             $filepath = dirname($srcfile);

            // 썸네일 생성             if(!$is_animated)                 $thumb_file = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, false);             else                 $thumb_file = $filename;

            if(!$thumb_file)                 continue;

            if ($width) {                 $thumb_tag = ''.$alt.'';             } else {                 $thumb_tag = ''.$alt.'';             }

            // $img_tag에 editor 경로가 있으면 원본보기 링크 추가             $img_tag = $matches[0][$i];             if(strpos($img_tag, G5_DATA_DIR.'/'.G5_EDITOR_DIR) && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) {                 $imgurl = str_replace(G5_URL, "", $src);                 $thumb_tag = ''.$thumb_tag.'';             }

            $contents = str_replace($img_tag, $thumb_tag, $contents);         }     }

    return $contents; }

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

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

bil/안에 있느 c 짜루 시작하는 파일 소스를 분석해보세요

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

답변에 대한 댓글 1개

수아주환
7년 전
도와주시는건 감사합니다..^^

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

스킨 폴더에 있는 리스트.php를 분석 해보세요 

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

답변에 대한 댓글 1개

수아주환
7년 전
아직 모르겠네요..^^

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

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

로그인