웹마스터 팁

modules/document/document.item.php 파일에 getThumbnail() 함수를 참고하여 원본 이미지 주소를 가져오도록 하였습니다.

목적은 widget_lightgallery_skin 의 경우 첨부파일에 대해서만 작동을 하는데 첨부파일이 아닌 본문 삽입 이미지인 경우에도 작동하도록 하기 위함입니다.

 

        /* 썸네일 방식으로 원본 이미지 주소 가져오기 */

        function getThumbnail_oriSrc_min()

        {

                // Return false if the document doesn't exist

                if(!$this->document_srl) return;

                // If not specify its height, create a square

                if(!$height) $height = $width;

                // Return false if neither attachement nor image files in the document

                if(!$this->get('uploaded_count') && !preg_match("!<img!is", $this->get('content'))) return;

                // Get thumbnai_type information from document module's configuration

                if(!in_array($thumbnail_type, array('crop','ratio')))

                {

                        $config = $GLOBALS['__document_config__'];

                        if(!$config)

                        {

                                $oDocumentModel = &getModel('document');

                                $config = $oDocumentModel->getDocumentConfig();

                                $GLOBALS['__document_config__'] = $config;

                        }

                        $thumbnail_type = $config->thumbnail_type;

                }

 

                        // thumb_image 강제 지정 기능 - sejin7940 ( 120714 - 시작)

                        $args->document_srl = $this->document_srl;

                        $output = executeQuery('document.getDocument', $args, $this->columnList);

                        $thumb_image_srl = $output->data->thumb_image;

                        if($thumb_image_srl) {

                                // Find an iamge file among attached files if exists

                                if($this->get('uploaded_count')) {

                                        $oFileModel = &getModel('file');

                                        $file_list = $oFileModel->getFiles($this->document_srl);

                                        if(count($file_list)) {

                                                foreach($file_list as $file) {

                                                        if($thumb_image_srl == $file->file_srl) {

                                                                if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue;

                                                                $source_file = $file->uploaded_filename;

                                                                if(!file_exists($source_file)) $source_file = null;

                                                                else break;

                                                        }

                                                }

                                        }

                                        if($source_file){

                                                                                                return $source_file;

                                        }

                                }

                        }

                        // thumb_image 강제 지정 기능 - sejin7940 ( 120714 - 끝)

 

                // Define thumbnail information

                // Target File

                $source_file = null;

                // Find an iamge file among attached files if exists

                if($this->get('uploaded_count'))

                {

                        $oFileModel = &getModel('file');

                        $file_list = $oFileModel->getFiles($this->document_srl, array(), 'file_srl', true);

                        if(count($file_list))

                        {

                                foreach($file_list as $file)

                                {

                                        if($file->direct_download!='Y') continue;

                                        if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue;

 

                                        $source_file = $file->uploaded_filename;

                                        if(!file_exists($source_file)) $source_file = null;

                                        else break;

                                }

                        }

                }

                // If not exists, file an image file from the content

                if(!$source_file)

                {

                        $content = $this->get('content');

                        $target_src = null;

                        preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER);

                        $cnt = count($matches);

                        for($i=0;$i<$cnt;$i++)

                        {

                                $target_src = trim($matches[$i][2]);

                                if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$target_src)) continue;

                                if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue;

                                else

                                {

                                        if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src;

 

                                                                                if(!$target_src) continue;

                                                                                else

                                                                                {

                                                                                            $source_file = $target_src;

                                                break;

                                                                                }

                                }

                        }

                }

 

                if($source_file)

                {

                                                return $source_file;

                }

 

                return;

        }

 
제목 글쓴이 날짜
대부분 쉬운설치로 인해 홈페이지 빈 페이지가 뜨는 에러는.. CJM 2019.10.24
xe 기본회원가입품 연락처항목 공백&숫자 유효성검사 질문입니다. 해운거사2 2019.08.25
[주옥시리즈] 내글 모니터링, 작성글 앞으로 뺴기 [6] socialskyo 2013.10.18
회원가입품 연락처항목 공백잇을시 질문입니다. 해운거사2 2019.08.16
VSCODE에서 PRETTIER-PHP 사용하기 (중급자용) reactux 2019.07.29
관리자페이지의 회원목록에서 타회원들의 비밀번호 찾기 질문/답변 수정 가능하도록 하려면.. sejin7940 2019.07.03
XE 코어의 메일전송을 우리알림 모듈로 대체하는 방법 [30] file GG 2014.11.24
XE 1.5.1로 사이트 꾸미기 Part 2 [11] file 황비 2011.12.06
스케치북5 게시판 사용자정의에 색상 적용하기 file 아데나 2019.05.31
로그인 실패시 실패내역 쪽지와 메일 발송 되는걸 발송 안 되게 하려면.. sejin7940 2019.05.21
스크랩버튼 외부로 빼내기 [3] RainDrop+ 2011.01.04
1.11.3 업로드 패치 이후 업로드 오류 관련 우소푸 2019.04.21
게시판 목록에서 바로 첨부파일 다운로드하기 [6] file 요다빈치 2012.03.13
XE이전 작업순서 elancer 2019.03.28
무료이미지 다운 받을 수 있는 곳 elancer 2019.03.19
회원이 글 삭제하면 삭제하지 않고 글을 다른 게시판으로 보내기 [5] SCAC 2012.07.03
트윗버튼, 페어스북 좋아요 버튼, 카카오스토리 좋아요 버튼 태그 elancer 2019.03.11
XE용 CKEditor v4.9.2 (다크 스킨 수정) [4] file 큰돌♡ 2018.07.04
file 모듈 insertFile() manual_insert 시 디렉토리생성 에러 문제 해결 방법 onTrust 2019.01.02
모듈에서 무조건 JSON/XML 형식으로 출력하기 [1] Devel0per 2015.04.03