웹마스터 팁
외부이미지 저장 애드온을 본문을 읽으면 작동하도록 하자!! 1.7.3적용
2013.03.16 00:20
카르마님의 외부이미지 저장 애드온을 가지고 사용중인데요.
기존 본문에 있는 이미지를 적용하기 위해서는 일부러 수정을 눌렀다가 저장을 해야 적용이 되는 불편한 점이 있었습니다.
오늘 푸시아님의 도움으로 편하게 본문을 읽어도 바로 외부이미지 저장기법이 적동되도록 수정하는데 성공했습니다.
원 애드온 소스는 카르마님의 사이트에 있구요.
저는 변경된 소스만 공유하도록 하겠습니다. ^^
if(!defined("__ZBXE__")) exit();
/**
* @outimage.addon.php
* @author 카르마(http://www.wildgreen.co.kr)
*
**/
$oDocumentModel = &getModel('document');
$act_arr = array('dispBoardContent','dispBodexContent','dispTextyle','dispBodexContentView','dispBoardContentView');
$document_act = array('dispBoardContent','procBoardInsertDocument','procBodexInsertDocument');
$comment_act = array('procBoardInsertComment','procBodexInsertComment');
$ri_avoid_domain = explode(',', $addon_info->ri_avoid_domain);
array_push($ri_avoid_domain,$_SERVER['HTTP_HOST']);
require_once('./addons/auto_outimage/auto_outimage.func.php');
if($addon_info->ri_permanent_get =='Y') {
if($called_position == 'after_module_proc' && in_array($this->act,$document_act) ) {
$var = $this->variables;
$document_srl = Context::get('document_srl');;
if(!$document_srl) return;
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
$args->document_srl = $document_srl;
$output = executeQuery('document.getDocument', $args);
$content = $output->data->content;
//$oDocument = $oDocumentModel->getDocument($document_srl);
//$content = $oDocument->getContent(false,false,false,false);
$upload_target_srl = $document_srl;
$oFileController = &getController('file');
$contImg = extractImage($content);
if(count($contImg)) {
$replace = $content;
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,'N');
if(strcmp($src,$ri_localfile)==true)
{
$url = parse_url($ri_localfile);
$path_parts = pathinfo($url['path']);
$file_info['name']=$path_parts['basename'];
$file_info['tmp_name']=$ri_localfile;
$file_obj = $oFileController->insertFile($file_info,$module_info->module_srl,$upload_target_srl,0,true);
if(@$file_obj->variables['uploaded_filename']!=null) $replace = str_replace($src,$file_obj->variables['uploaded_filename'],$replace);
@unlink($ri_localfile);
}
}
$obj->module_srl = $module_info->module_srl;
$obj->content = $replace;
$obj->document_srl = $document_srl;
executeQuery('addons.auto_outimage.updateDocument', $obj);
}
} elseif($addon_info->ri_comment_get != 'N' && $called_position == 'after_module_proc' && in_array($this->act,$comment_act)) {
$var = $this->variables;
$document_srl = $var[document_srl];
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
$comment_srl = $var[comment_srl];
if(!$comment_srl) return;
$oCommentModel = &getModel('comment');
$comment = $oCommentModel->getComment($comment_srl);
$content = $comment->getContent(false,false,false,false);
$upload_target_srl = $comment_srl;
$oFileController = &getController('file');
$contImg = extractImage($content);
if(count($contImg)) {
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,'N');
if(strcmp($src,$ri_localfile)==true)
{
$url = parse_url($ri_localfile);
$path_parts = pathinfo($url['path']);
$file_info['name']=$path_parts['basename'];
$file_info['tmp_name']=$ri_localfile;
$file_obj = $oFileController->insertFile($file_info,$module_info->module_srl,$upload_target_srl,0,true);
if(@$file_obj->variables['uploaded_filename']!=null) $replace = str_replace($src,$file_obj->variables['uploaded_filename'],$replace);
@unlink($ri_localfile);
}
}
$obj->module_srl = $module_info->module_srl;
$obj->content = $content;
$obj->comment_srl = $comment_srl;
$output = executeQuery('addons.auto_outimage.updateComment', $obj);
}
}
} else {
$document_srl = Context::get('document_srl');
if(!$document_srl) return;
$current_module_info = Context::get('current_module_info');
$oView = &getView($current_module_info->module);
$act = $oView->act;
if($_COOKIE['mobile'] || in_array($act,$act_arr) && $called_position == 'before_display_content') {
$oDocument = $oDocumentModel->getDocument($document_srl);
$content = $oDocument->getContent(false,false,false,false);
$_comment_list = $oDocument->getComments();
$contImg = extractImage($content);
if(count($contImg)) {
$replace = $content;
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,$addon_info->ri_permanent_get);
$replace = str_replace($src,$ri_localfile,$replace);
}
$output = str_replace($content,$replace,$output);
}
if($addon_info->ri_comment_get == 'Y' && $oDocument->getCommentCount()) {
$pattern_comments_area = '/<div class="comment_[0-9]+_[0-9]+ xe_content">(.*?)<!--AfterComment\([0-9]+,[0-9]+\)-->/is';
preg_match_all($pattern_comments_area, $output,$match);
if(!count($match[0])) return;
foreach ($match[0] as $comment) {
$list = extractImage($comment);
if(count($list)) {
$repcom = $comment;
foreach($list as $rfile) {
$ri_localfile = geRitLocalFile($rfile,$ri_avoid_domain,$addon_info->ri_permanent_get);
$repcom = str_replace($rfile,$ri_localfile,$repcom);
}
$output = str_replace($comment,$repcom,$output);
}
}
}
}
}
?>
댓글 18
-
꿈틀잉
2013.03.16 02:09
-
하얀마법
2013.03.16 02:16
이 소스를 쓰시면 그 문제도 함께 해결됩니다. ^^
-
KTK
2013.03.21 20:42
하얀마법님... 혹시 게시글 불러와서 자동 등록되는거 성공하셨나요 ㅠㅠ
좀알려주시면 감사하겠습니다 ㅠㅠ 부탁드립니다...
-
꿈틀잉
2013.03.16 02:21
우어어~~ 대박입니다. 잘되는데요^^
정보 감사합니다..
-
비밀얌
2013.03.16 03:05
카르마님 웹사이트에 가입하려고 했는데 오류가 발생하네요 그래서 다운로드를 못함.. ㅠ
-
CMD
2013.03.16 06:18
모든 파일을 압축해서 zip파일로 올려주시면 감사드릴께요~
-
브레인630
2013.03.18 10:04
ㅋ... 저도 이거 때문에 카르마님 사이트에 가입하려고 하다가 가입이 안되서...
어쩌지 못하고 있었는데... 쩝... 저도 애드온 파일 좀 올려주세요..^^:
아니면 메일로라도...ㅎㅎ.. brain630@naver.com 입니다... 감사합니다. ^^:
-
samsara
2013.03.20 07:56
auto_outimage.func.php 에는 어떤 내용이 들어 있는지 궁금합니다. 아시는 분 계시면 쪽지 부탁드립니다.
-
ㅈㅔㅃㅣ
2013.03.21 21:54
auto_image.addon.php 를 수정하는 것 맞지요? 저는 수정했는데 왜 동작을 안하는지 모르겠네요..
파일을 올려주심 안될까요?
-
socialskyo
2013.03.21 22:22
@하얀마법님 정말 고맙습니다. 1.7에서 동작도 하고 덕분에 광명을 찾았습니다.
-
소영짜응
2013.03.22 19:11
-
김 기 상
2013.03.23 11:17
소스 복사하여 올려보았더니 잘 안되네요
저에게도 좀 부탁드립니다. kimkisang@gmail.com
-
socialskyo
2013.03.24 15:19
@하얀마법님 제가 포럼모듈을 사용 중에 있습니다. 포럼모듈에서도 동작되게 수정 가능 하실까요?
-
CMD
2013.03.27 07:02
원본 파일 auto_outimage0.4.7.zip
-
짤막한글
2013.06.22 20:54
킁... 저는 수정을 해도 안되네요... 버전 1.7.4.0인데..
-
ToFinder
2014.01.10 12:18
1.7.3.7 버전에서 사용 테스트 해보았습니다.
localhost 에 등록되어진 테스트용에서 사용해보았으며 정상작동 하더군요.
버전은 동일합니다.
-
안엉어웅넌223
2014.07.22 16:11
수정눌러야 이미지 들어가는데요?...
-
불금
2015.06.09 23:47
첨부파일로 만들어지나
수정후 등록해야 그 게시물의 첨부파일이 되네요 그전에는 "대기" 파일로...
제목 | 글쓴이 | 날짜 |
---|---|---|
각 OS별 브라우저별 자신의 웹사이트 보기??? [12] | 세바스챤_™ | 2008.01.31 |
리눅스 호환 호스팅에서 zbxe 전체 업로드 후 디렉토리 이동시키기... [4] | 소마세월 | 2008.02.02 |
포인트 수정없이 원하는 레벨 아이콘이나 원하는 이미지 출력하기(0.29용) [20] | 지연아빠 | 2008.02.02 |
flash <=> xe menu 연동 [7] | tsana | 2008.02.03 |
특정 게시판, 업로드된 그림 자동으로 본문에 출력하기 [14] | 대암지기 | 2008.02.03 |
본인외 회원정보 제어 [1] | edgarkim | 2008.02.03 |
BGM 등을 배경을 투명하게 iframe 으로 넣는 팁 [3] | 푸른커튼 | 2008.02.05 |
왼쪽메뉴줄이고 오른쪽에 박스만들어 내용쉽게넣기 [15] | plruto | 2008.02.07 |
주소끝에 /zbxe 안적어도 홈페이지에 바로 들어오게 하는법?? [10] | 박태훈922 | 2008.02.07 |
HTTP 406 Error 가 나오면서 업로드 안될때 [16] | plruto | 2008.02.08 |
아날로그 플래시 시계 10종류 (홈페이지, 블로그용) | 푸른커튼 | 2008.02.09 |
이미지 줌 아웃슬라이드 [4] | 맨발 | 2008.02.10 |
로그인후 보여줄 페이지 설정 [4] | 권인해 | 2008.02.11 |
회원가입 생일 필수로 입력받고, 관리자페이지 회원목록에 회원생일 출력하기 [10] | 대암지기 | 2008.02.11 |
제로보드용 플래시시계 위젯 설치방법 | 푸른커튼 | 2008.02.12 |
드림위버 등에서 레이아웃 편집시에.. [3] | 은진아빠 | 2008.02.12 |
특정게시판, 비밀글로 작성하기 [19] | 대암지기 | 2008.02.13 |
전에 누군가 찾았던 것인데..새로고침시 현재페이지로 [2] | 강영곤 | 2008.02.14 |
zbXE User Guide - 3차수정 [3] | 캬캬캬캬캬캬 | 2008.02.16 |
[전면수정]회원가입시 기본 정보공개 여부 체크하기(2) 스킨부분 | 대암지기 | 2008.02.17 |
좋은팁 감사합니다.
지금팁에서 수정을 눌렀을떼 첨부파일 리스트에 자동들어가게 하는건
힘든가요?
files/out에 저장된다고 해도 실질적으로 게시물에 첨부이미지가 없이 나와서 그렇습니다.