웹마스터 팁

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;

        }

 
제목 글쓴이 날짜
EXIF 메타정보 필요하신 분 있으시면 forest535 2018.04.09
게시판 본문읽기에서 컨텐츠 이미지와 텍스트 분리하여 출력하기 forest535 2018.04.09
관리권한 없이도 특정그룹에게 비밀글 열람 및 댓글작성 권한 부여하는 방법 ( 부운영자등을 위해) sejin7940 2018.04.26
[PHP] 이름 및 연락처 마스킹 처리 [1] ppumweb 2018.05.21
단축url API 사용하시는 분들... 미스터강 2018.06.01
게시판글 엑셀 파일 보내기 php7용 file 황금날개 2018.06.05
도메인 변경 또는 설치 폴더 변경시 이미지 주소변경하기 file 해피정닷컴 2018.06.08
XE용 CKEditor v4.9.2 (다크 스킨 수정) [4] file 큰돌♡ 2018.07.04
DB를 손쉽게 관리 [1] EISOFT 2018.07.15
Code-Highlighter 3.0.83 가로 스크롤바를 어디론가 보내 버리고 싶으신 분. 달빛늑대 2018.07.16
Google 스프레드시트에서 구글 번역으로 XE 다국어 내용 만들기(Lang.xml 용도) file 달빛늑대 2018.07.17
act로 다른 페이지 보여주기 [1] 이온디 2018.07.25
다른 서버 간 서브도메인 쿠키 공유 에이트 2018.08.04
썸네일 방식으로 이미지 원본 주소 가져오기 에이트 2018.08.22
PHP 뮤텍스 락 설치법(memcached 활용) [1] 에이트 2018.09.03
PHP 뮤텍스 락 설치법(redis 활용) 에이트 2018.09.11
무료 psd, html 탬플릿, 아이콘 사이트공유합니다. 허허길드짱 2018.11.27
file 모듈 insertFile() manual_insert 시 디렉토리생성 에러 문제 해결 방법 onTrust 2019.01.02
트윗버튼, 페어스북 좋아요 버튼, 카카오스토리 좋아요 버튼 태그 elancer 2019.03.11
무료이미지 다운 받을 수 있는 곳 elancer 2019.03.19