첨부화일 이미지 및 에디터 첨부 이미지 클릭/팝업 안되게 하기 (불당 리사이즈 포함) 정보
첨부화일 이미지 및 에디터 첨부 이미지 클릭/팝업 안되게 하기 (불당 리사이즈 포함)
본문
다른분들이 알려주신 내용들 + 저의 노력의 결정판입니다.
불당 리사이즈를 사용하지 않는 분은 불당 부분을 건너뛰시면 됩니다.
* 불당 resize 자체에 첨부 이미지 클릭시 새창뜨기가 포함되어 있음 이 기능을 제거하기 위해서는
extend/b4.lib.php 파일의 아래 내용을 주석처리함
/* // onclick을 했을 때, 원래의 이미지 크기로 popup이 되도록 변경
if ($board[image_window]) {
if (isset($img[onclick]) == true)
$return = preg_replace('/onclick\=(\'|\")?[^\s\'\"]+(\'|\")?/i', 'onClick="image_window3(\'' . $img['src'] . '\',' . (int)$img_width . ',' . (int)$img_height . ')" ', $return);
else
$return = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 onClick='image_window3(\"" . $img['src'] . "\"," . (int)$img_width . "," . (int)$img_height . ")' \\2 \\3", $return);
} else {
if (isset($img[onclick]) == true)
$return = preg_replace('/onclick\=(\'|\")?[^\s\'\"]+(\'|\")?/i', '', $return);
else
$return = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 onclick='' \\2 \\3", $return);
}
}
else
{
// width를 조정
if (isset($img['width']) == true)
$return = preg_replace('/width\=(\'|\")?[^\s\'\"]+(\'|\")?/i', 'width="' . $img_width . '"', $return);
else
$return = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 width='" . $img_width . "' \\2 \\3", $return);
// height를 삭제
$return = preg_replace('/height\=(\'|\")?[^\s\'\"]+(\'|\")?/i', null, $return);
// 이름도 그누의 javascript resize할 수 있게 수정
if (isset($img[name]) == true)
$return = preg_replace('/name\=(\'|\")?[^\s\'\"]+(\'|\")?/i', ' name="target_resize_image[]" ', $return);
else
$return = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 name='target_resize_image[]' \\2 \\3", $return);
// $thumb_create가 true이면, 이미지 크기가 $max_img_width보다 작지만, 그래도 thumb를 생성
if ($thumb_create && $thumb_path) {
include_once("$g4[path]/lib/thumb.lib.php");
$thumb_path=thumbnail($thumb_path, $max_img_width,$max_img_height,$is_create,$is_crop,$quality, "", "", $filter);
$return = preg_replace('/src\=(\'|\")?[^\s\'\"]+(\'|\")?/i', 'src="' . $thumb_path . '"', $return);
}
// onclick을 했을 때, 원래의 이미지 크기로 popup이 되도록 변경
if ($board[image_window]) {
if (isset($img[onclick]) == true)
$return = preg_replace('/onClick\=(\'|\")?[^\s\'\"]+(\'|\")?/i', 'onClick="image_window3(\'' . $img['src'] . '\',' . (int)$img_width . ',' . (int)$img_height . ')" ', $return);
else
$return = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 onClick='image_window3(\"" . $img['src'] . "\"," . (int)$img_width . "," . (int)$img_height . ")' \\2 \\3", $return);
} else {
if (isset($img[onclick]) == true)
$return = preg_replace('/onClick\=(\'|\")?[^\s\'\"]+(\'|\")?/i', '', $return);
else
$return = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 onClick='' \\2 \\3", $return);
}
*/
그래도 그누보드 자체의 첨부 이미지 팝업 기능은 여전히 영향을 미치기 때문에
lib/common.lib.php의
return "<img src='$g4[path]/data/file/$board[bo_table]/".urlencode($file)."' name='target_resize_image[]' onclick='image_window(this);' style='cursor:pointer;' title='$content'>";
를
return "<img src='$g4[path]/data/file/$board[bo_table]/".urlencode($file)."' name='target_resize_image[]' >";
로 수정
그럼에도 불구하고 editor로 첨부한 이미지는 여전히 팝업됨. 이것을 종결하기 위해서
bbs/view.php의 아래 내용을 주석처리함
//$view[content] = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 name='target_resize_image[]' onclick='image_window(this)' style='cursor:pointer;' \\2 \\3", $view[content]);
6
댓글 7개
링크 싫어하면 써먹어야겠네요 감사감사

