|
|
|
16년 전
|
조회 1,259
|
|
|
|
16년 전
|
조회 1,156
|
|
|
|
16년 전
|
조회 1,187
|
|
|
|
16년 전
|
조회 1,265
|
|
|
|
16년 전
|
조회 1,139
|
|
|
|
16년 전
|
조회 1,547
|
|
|
|
16년 전
|
조회 1,300
|
|
|
|
16년 전
|
조회 1,662
|
|
|
|
16년 전
|
조회 7,748
|
|
|
|
16년 전
|
조회 1,098
|
|
|
|
16년 전
|
조회 1,041
|
|
|
|
16년 전
|
조회 1,192
|
|
|
|
16년 전
|
조회 1,154
|
|
|
|
16년 전
|
조회 1,139
|
|
|
|
16년 전
|
조회 5,825
|
|
|
|
16년 전
|
조회 1,190
|
|
|
|
16년 전
|
조회 1,192
|
|
|
|
16년 전
|
조회 1,202
|
|
|
|
16년 전
|
조회 1,105
|
|
|
|
16년 전
|
조회 1,218
|
|
|
|
16년 전
|
조회 1,161
|
|
|
|
16년 전
|
조회 1,132
|
|
|
|
16년 전
|
조회 1,087
|
|
|
|
16년 전
|
조회 1,129
|
|
|
|
16년 전
|
조회 1,077
|
|
|
|
16년 전
|
조회 1,096
|
|
|
|
16년 전
|
조회 1,241
|
|
|
|
16년 전
|
조회 1,109
|
|
|
|
16년 전
|
조회 1,703
|
|
|
|
16년 전
|
조회 1,125
|
댓글 13개
echo preg_replace_callback('/\<img[^\<\>]*\>/i', 'resize', $view['content']);
// common.lib.php에 추가?
function resize($img)
{
global $board;
$return = $img['0'];
// width값은 $board에 정의된 값으로 수정
$return = preg_replace('/width\=(\'|\")?[0-9]+(\'|\")?/i', 'width=' . $board['bo_image_width'], $return);
// height값은 삭제
$return = preg_replace('/height\=(\'|\")?[0-9]+(\'|\")?/i', null, $return);
return $return;
}
대충 이런식으로 하면??? 아침이라 정신이 없어서ㅠㅠ
ps. 아, width가 설정값보다 작을때는 그냥 리턴해야되니까 resize함수는 수정해야겠네요;;;
외근갔다와서 다시 한번 볼께요, 이젠 개발자도 영업으로 고고씽~~~
css 리사이징은 expression이 비표준?이어서 그냥 넘어가구요;;;
불당님 말처럼
- width와 height 값이 있으면 그걸로 resize
- 값이 없으면 이미지 정보를 읽어와서 resize
function resize($string)
{
global $board;
$return = $string['0'];
preg_match_all('@(?P<attribute>[^\s\'\"]+)\s*=\s*(\'|\")?(?P<value>[^\s\'\"]+)(\'|\")?@i', $return, $match);
$img = array_change_key_case(array_combine($match['attribute'], $match['value']));
if(isset($img['width']) == false) list($img['width']) = getimagesize($img['src']);
if($img['width'] > $board['bo_image_width'])
{
$return = preg_replace('/width\=(\'|\")?[0-9]+(\'|\")?/i', 'width=' . $board['bo_image_width'], $return);
$return = preg_replace('/height\=(\'|\")?[0-9]+(\'|\")?/i', null, $return);
}
return $return;
}
정규식 잘하시는 분들 넘 부러워요.
src에 thumbnail을 만드는 코드 넣는거는 어떻게 해야 할까요???
---
3. src="파일명" ...
이것을 thumbnail을 적용할 수 있게 src="프로그램이름/파일명" 처럼 할 수 있게
하는 것도 가능할까요??
---
글쿠 width, height 정보를 없앴더니, 파일이 있슴에도 오류가 나와요. ㅠ..ㅠ...
Warning: getimagesize(/data/cheditor4/0902/KQc2bR8ax.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/democode/public_html/skin/board/cheditor/view.skin.php on line 150
http://demo.opencode.co.kr/bbs/board.php?bo_table=test2&wr_id=8
$body .= '<a href="test2"><img src="파일명2" width="101px" height="201px">가나다라마바사</a>';
$matches = array();
$patterns = '<img.*?src=(\'|\")(.*?"|\')';
preg_match_all('/'.$patterns.'/', $body, $matches);
foreach($matches[2] as $value) {
$value2 = "프로그램명/".$value;
$body = str_replace($value, $value2, $body);
}
속도 보장은 못합니다...ㄷㄷ;;
예를 들어 <img width=100 height=200 style=border:0 src=a.gif>일수도 있거든요...
preg_match_all을 쓰면 원하지 않는 속성값이 변경될 수도ㅠㅠ
$body .= '<a href="test2"><img width=100 height=200 style=border:0 src=a.gif><img src="파일명2" width="101px" height="201px">가나다라마바사</a>';
$matches = array();
$patterns = '<img.*?src=(\'|\"|)(.*?"|\')';
preg_match_all('/'.$patterns.'/', $body, $matches);
foreach($matches[2] as $value) {
$value2 = "프로그램명/".$value;
$body = str_replace($value, $value2, $body);
}
음.. 다른건 둘째치고 위와 같은 소스면
다른 속성값은 변경 안되지 않을까요??
궁금해서 물어봅니다..ㄷㄷ
서누님말대로 다른 속성값은 변동이 없겠네요^^
그건 에디터제작자의 맘이겠죠ㅠㅠ 음, cheditor는 절대경로로 들어가네보내요.
global에 $g4를 선언해주고 getimagesize($g4['path'] . $img['src']); 로 수정해보세요.
ps. 생각해보니 작성자가 html을 직접 입력해서 외부경로에 있는 이미지를 넣는 경우도 있겠네요.
그러면 getimagesize를 사용못할수도 있고 썸네일생성도 무용지물이 되죠. (엑세스거부)
관리자님이 자바로 하는 이유가 있었나 봅니다
function resize($string)
{
global $board, $g4;
$return = $string['0'];
preg_match_all('@(?P<attribute>[^\s\'\"]+)\s*=\s*(\'|\")?(?P<value>[^\s\'\"]+)(\'|\")?@i', $return, $match);
$img = array_change_key_case(array_combine($match['attribute'], $match['value']));
if(isset($img['width']) == false && preg_match('/^(http|ftp)/i', $img['src']) == false) list($img['width']) = getimagesize($g4['path'] . $img['src']);
if($img['width'] > $board['bo_image_width'])
{
$return = preg_replace('/width\=(\'|\")?[0-9]+(\'|\")?/i', 'width=' . $board['bo_image_width'], $return);
$return = preg_replace('/height\=(\'|\")?[0-9]+(\'|\")?/i', null, $return);
// 썸네일생성이라면 위의 두줄 주석처리한 후 아래값 주석해제
// $return = thumbnamil(경로, 가로);
}
return $return;
}
function thumbnail(경로, 가로)
{
// 가로크기에 맞추어 썸네일을 생성하는 코드입력
....
// 아래처럼 리턴값은 이미지태그를 리턴하면 되겠죠^^
$return = "<img src='위코드에서 생성한 썸네일경로' />";
return $return;
}
... 생략 ...
$return = preg_replace('/height\=(\'|\")?[0-9]+(\'|\")?/i', null, $return);
$thumb = thumbnail(경로, 가로);
$return = preg_replace('/src\=(\'|\")?[^\s\'\"]+(\'|\")?/i', 'src=' . $thumb, $return);
... 생략 ...
그리고 썸네일함수는 경로만 리턴하는 거로 하시면 되겠네요^^
아~ 이제 퇴근할랍니다. 불당님이 잘 궁리하셔셔 팁 올려주세요
http://shiftingpixel.com/2008/03/03/smart-image-resizer/
원하는게 이것 같은데 맞는가 모르겠네요.