From e1fb2464c77b9fa588682d92dd5933230237e5b5 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 12 Dec 2013 13:47:37 +0900 Subject: [PATCH] =?UTF-8?q?cheditor=20=EC=97=90=EC=84=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=82=AC=EC=9D=B4=EC=A6=88=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=9C=EB=8C=80=EB=A1=9C=20=EB=85=B8=EC=B6=9C?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common.lib.php | 3 ++- lib/thumbnail.lib.php | 39 +++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/lib/common.lib.php b/lib/common.lib.php index 0233a5b4b..62146cad1 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -2006,7 +2006,8 @@ function get_editor_image($contents) return false; // $contents 중 img 태그 추출 - $pattern = "/]*src=[\'\"]?([^>\'\"]+[^>\'\"]+)[\'\"]?[^>]*>/"; + //$pattern = "/]*src=[\'\"]?([^>\'\"]+[^>\'\"]+)[\'\"]?[^>]*>/"; + $pattern = "/]*)>/iS"; preg_match_all($pattern, $contents, $matchs); return $matchs; diff --git a/lib/thumbnail.lib.php b/lib/thumbnail.lib.php index ceb3e4579..31f4b7e7f 100644 --- a/lib/thumbnail.lib.php +++ b/lib/thumbnail.lib.php @@ -22,13 +22,13 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_ $write_table = $g5['write_prefix'].$bo_table; $sql = " select wr_content from $write_table where wr_id = '$wr_id' "; $write = sql_fetch($sql); - $matchs = get_editor_image($write['wr_content']); + $matches = get_editor_image($write['wr_content']); $edt = true; - for($i=0; $i\'\"]+[^>\'\"]+)/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]; + // 이미지 path 구함 - $p = parse_url($matchs[1][$i]); + $p = parse_url($src); if(strpos($p['path'], "/data/") != 0) $data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']); else @@ -154,14 +165,18 @@ function get_view_thumbnail($contents, $thumb_width=0) else $thumb_file = $filename; - $img_tag = $matchs[0][$i]; preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img_tag, $malt); $alt = get_text($malt[1]); - $thumb_tag = ''.$alt.''; + if ($width) { + $thumb_tag = ''.$alt.''; + } else { + $thumb_tag = ''.$alt.''; + } // $img_tag에 editor 경로가 있으면 원본보기 링크 추가 - if(strpos($matchs[1][$i], 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) { - $imgurl = str_replace(G5_URL, "", $matchs[1][$i]); + $img_tag = $matches[0][$i]; + if(strpos($img_tag, 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) { + $imgurl = str_replace(G5_URL, "", $img_tag); $thumb_tag = ''.$thumb_tag.''; }