에디터로 올린 이미지를 먼저 썸네일로만들고 싶습니다. 채택완료
바흐
7년 전
조회 3,392
아래에 긴 코드가 있는데 궁금한것이 있습니다.
1. $write['img_rows'] 가 무엇을 찾는것인지 궁금합니다. echo $rows; 로 하면 값이 1이 나오긴하는데... 그 값 1이 무엇을 의미하는지 모르겠네요...
$rows = (isset($write['img_rows']) && $write['img_rows'] > 1) ? $write['img_rows'] : 1;
2. 첨부파일에 이미지가 있으면 우선 썸네일을 생성하는데 어느 부분을 수정해야 에디터로 올린 이미지를 먼저 썸네일로 수정할 수 있을까요...
긴 코드를 적어놔 죄송합니다.
</p>
<p>// 게시물 썸네일 생성
function apms_wr_thumbnail($bo_table, $write, $thumb_width, $thumb_height, $is_create=false, $is_crop=false, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3') {
global $g5, $config;</p>
<p> $img = array();
$limg = array();
$lalt = array();
$link = array();
$thumb = array();
$no_thumb = array('is_thumb'=>false, 'src'=>'', 'alt'=>'', 'org'=>'', 'height'=>'');</p>
<p> $chk_img = (isset($write['chk_img']) && $write['chk_img']) ? true : false; // Check Image
$rows = (isset($write['img_rows']) && $write['img_rows'] > 1) ? $write['img_rows'] : 1;</p>
<p> echo $write['img_rows'];</p>
<p> // 비밀글 & 블라인드글
if (strstr($write['wr_option'], 'secret') || $write['as_shingo'] < 0) {</p>
<p> if($chk_img) return 0;</p>
<p> if($rows > 1) {
$thumb[0] = $no_thumb;
} else {
$thumb = $no_thumb;
}
return $thumb;
}</p>
<p> $is_thumb = (!$chk_img && isset($write['as_thumb']) && $write['as_thumb'] && $rows == "1") ? true : false;
$is_thumb_no = (isset($write['is_thumb_no']) && $write['is_thumb_no']) ? true : false;
$no_img = (isset($write['no_img']) && $write['no_img']) ? $write['no_img'] : '';</p>
<p> $make_thumb = true;
if($is_thumb && isset($write['as_thumb']) && $write['as_thumb'] == '1') {
$z = 0;
$make_thumb = false;
unset($write);
} else if($is_thumb) {
$tmp_thumb = apms_video_thumbnail($write['as_thumb'], 1);
if($tmp_thumb) {
$z = 1;
$img[0]['img'] = $tmp_thumb;
$img[0]['alt'] = '';
$make_thumb = false;
unset($write);
}
}</p>
<p> if($make_thumb) {
$wr_id = $write['wr_id'];
$wr_content = $write['wr_content'];</p>
<p> // 링크
for ($i=1; $i<=G5_LINK_COUNT; $i++) {
$link[$i] = get_text($write["wr_link{$i}"]);
}</p>
<p> unset($write);</p>
<p> $result = sql_query(" select bf_file, bf_content from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_type between '1' and '3' order by bf_no", false);
$z = 0;
for ($i=0; $row=sql_fetch_array($result); $i++) {
if($row['bf_file']) {
$img[$z]['alt'] = get_text($row['bf_content']);
$img[$z]['img'] = G5_DATA_URL.'/file/'.$bo_table.'/'.$row['bf_file'];
$z++;
if($z == $rows) break;
}
}</p>
<p> if($z != $rows) {
if(!$wr_content) {
$write_table = $g5['write_prefix'].$bo_table;
$sql = " select wr_content from $write_table where wr_id = '$wr_id' ";
$write = sql_fetch($sql);
$wr_content = $write['wr_content'];
}
$matches = get_editor_image($wr_content, false);
$edt = true;</p>
<p> 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'];</p>
<p> $srcfile = G5_PATH.$data_path;</p>
<p> if(is_file($srcfile)) {
$size = @getimagesize($srcfile);
if(empty($size)) {
continue;
}</p>
<p> $img[$z]['img'] = $matches[1][$i];</p>
<p> preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matches[0][$i], $malt);
$img[$z]['alt'] = get_text($malt[1]);</p>
<p> $z++;
if($z == $rows) break;</p>
<p> } else {
$limg[] = $matches[1][$i];
preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matches[0][$i], $malt);
$lalt[] = get_text($malt[1]);
}
}
}</p>
<p> if($z != $rows) { // 링크동영상 체크
for ($i=1; $i <= count($link); $i++) {</p>
<p> $video = apms_video_info($link[$i]);</p>
<p> if(!$video['type']) continue;</p>
<p> $srcfile = apms_video_img($video['video_url'], $video['vid'], $video['type'], $video['img']);</p>
<p> if(!$srcfile || $srcfile == 'none') continue;</p>
<p> $size = @getimagesize($srcfile);
if(empty($size)) {
continue;
}</p>
<p> $img[$z]['img'] = str_replace(G5_PATH, G5_URL, $srcfile);</p>
<p> $z++;
if($z == $rows) break;
}
}</p>
<p> if($z != $rows) { //본문동영상 이미지 체크
if(preg_match_all("/{(동영상|video)\:([^}]*)}/is", $wr_content, $match)) {
$match_cnt = count($match[2]);
for ($i=0; $i < $match_cnt; $i++) {
$video = apms_video_info(trim(strip_tags($match[2][$i])));</p>
<p> if(!$video['type']) continue;</p>
<p> $srcfile = apms_video_img($video['video_url'], $video['vid'], $video['type'], $video['img']);</p>
<p> if(!$srcfile || $srcfile == 'none') continue;</p>
<p> $size = @getimagesize($srcfile);
if(empty($size)) {
continue;
}</p>
<p> $img[$z]['img'] = str_replace(G5_PATH, G5_URL, $srcfile);</p>
<p> $z++;
if($z == $rows) break;
}
}
}</p>
<p> if($z != $rows) { //링크 이미지
for($i=0; $i < count($limg); $i++) {
$img[$z]['img'] = $limg[$i];
$img[$z]['alt'] = $lalt[$i];</p>
<p> $z++;
if($z == $rows) break;
}
}
}</p>
<p> // Check Image
if($chk_img) {
$chk_img = (isset($img[0]['img']) && $img[0]['img']) ? $img[0]['img'] : 0;
return $chk_img;
}</p>
<p> if($z == 0) {
if($no_img) {
$img[$z]['org'] = $no_img;
$img[$z]['img'] = $no_img;
$img[$z]['alt'] = '';
} else {
if($rows > 1) {
$thumb[0] = $no_thumb;
} else {
$thumb = $no_thumb;
}
return $thumb;
}
}</p>
<p> // 썸네일
$tmp = array();
$j = 0;
for($i = 0; $i < count($img); $i++) {
if($thumb_width > 0 && !$is_thumb_no) {</p>
<p> $tmpimg = apms_thumbnail($img[$i]['img'], $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);</p>
<p> if(!$tmpimg['src']) continue;</p>
<p> $tmp[$j]['is_thumb'] = $tmpimg['is_thumb'];
$tmp[$j]['src'] = $tmpimg['src'];
$tmp[$j]['height'] = $tmpimg['height'];
} else {
$tmp[$j]['is_thumb'] = false;
$tmp[$j]['src'] = $img[$i]['img'];
$tmp[$j]['height'] = '';
}
$tmp[$j]['org'] = $img[$i]['img'];
$tmp[$j]['alt'] = $img[$i]['alt'];
$j++;
}</p>
<p> if($j == 0) {
if($rows > 1) {
$thumb[0] = $no_thumb;
} else {
$thumb = $no_thumb;
}
} else {
$thumb = ($rows > 1) ? $tmp : $tmp[0];
}</p>
<p> return $thumb;
}
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
7년 전
1. $write['img_rows']는 추출할 이미지의 갯수를 의미합니다.
2. 아래와 같이 소스의 위치를 바꾸면 됩니다.
</p>
<p> $z = 0;</p>
<p> if(!$wr_content) {</p>
<p> $write_table = $g5['write_prefix'].$bo_table;</p>
<p> $sql = " select wr_content from $write_table where wr_id = '$wr_id' ";</p>
<p> $write = sql_fetch($sql);</p>
<p> $wr_content = $write['wr_content'];</p>
<p> }</p>
<p> $matches = get_editor_image($wr_content, false);</p>
<p> $edt = true;</p>
<p> </p>
<p> for($i=0; $i<count($matches[1]); $i++) {</p>
<p> // 이미지 path 구함</p>
<p> $p = @parse_url($matches[1][$i]);</p>
<p> if(strpos($p['path'], '/'.G5_DATA_DIR.'/') != 0)</p>
<p> $data_path = preg_replace('/^\/.*\/'.G5_DATA_DIR.'/', '/'.G5_DATA_DIR, $p['path']);</p>
<p> else</p>
<p> $data_path = $p['path'];</p>
<p> </p>
<p> $srcfile = G5_PATH.$data_path;</p>
<p> </p>
<p> if(is_file($srcfile)) {</p>
<p> $size = @getimagesize($srcfile);</p>
<p> if(empty($size)) {</p>
<p> continue;</p>
<p> }</p>
<p> </p>
<p> $img[$z]['img'] = $matches[1][$i];</p>
<p> </p>
<p> preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matches[0][$i], $malt);</p>
<p> $img[$z]['alt'] = get_text($malt[1]);</p>
<p> </p>
<p> $z++;</p>
<p> if($z == $rows) break;</p>
<p> </p>
<p> } else {</p>
<p> $limg[] = $matches[1][$i];</p>
<p> preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matches[0][$i], $malt);</p>
<p> $lalt[] = get_text($malt[1]);</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> if($z != $rows) {</p>
<p> $result = sql_query(" select bf_file, bf_content from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_type between '1' and '3' order by bf_no", false);</p>
<p> for ($i=0; $row=sql_fetch_array($result); $i++) {</p>
<p> if($row['bf_file']) {</p>
<p> $img[$z]['alt'] = get_text($row['bf_content']);</p>
<p> $img[$z]['img'] = G5_DATA_URL.'/file/'.$bo_table.'/'.$row['bf_file'];</p>
<p> </p>
<p> $z++;</p>
<p> if($z == $rows) break;</p>
<p> }</p>
<p> } </p>
<p> }</p>
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 2개
�
바흐
7년 전
e
eyekiss
7년 전
apms_wr_thumbnail() 를 호출하는 페이지에서 찾아야합니다.
소스가 없어서 정확히는 모르겠네요..^^;;
소스가 없어서 정확히는 모르겠네요..^^;;
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
그리고 한가지 더 궁금한게있는데
$write['chk_img'] 와 같이 chk_img는 대충 어떤의미인진알겠는데 chk_img 같은것은 어디에 정의되어있는건가요?
답변주셔서 감사합니다. 즐거운 하루되세요....