웹마스터 팁
썸네일 방식으로 이미지 원본 주소 가져오기
2018.08.22 11:44
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;
}
댓글 0
제목 | 글쓴이 | 날짜 |
---|---|---|
서브 메뉴 배경색 바꾸기 [4] | Chang-Jo(창조) | 2007.08.17 |
위지웍 에디터 웹폰트 사용하기 [6] | 최지연 | 2007.08.17 |
사이트접속시 제로보드XE폴더로 이동되게 하는 쉬운방법 [8] | 부찬™ | 2007.08.17 |
리눅스에서 제로보드 xe를 위한 환경 구축하기 [6] | 써니a | 2007.08.18 |
404 페이지 못찾음으로 나오는 문제 수정 [9] | 화니군 | 2007.08.18 |
한글 경로가 404 에러로 뜨는 경우 처리방법 [2] | 베니 | 2007.08.18 |
본문 하단에 (애드센스)광고 넣기 [2] | roresy | 2007.08.19 |
각 메뉴 옆에 게시물 갯수 표시하기 [6] | coolsushi | 2007.08.19 |
게시판에 나타나는 이름을 실명으로 나타내자! [5] | 박영주964 | 2007.08.19 |
OpenID 적용 [6] | 맑은하늘75 | 2007.08.20 |
(수정) ZBXE 설치/로그인 등이 안될 때 시도해보세요. (MySQL DB) | 핑크플로이드 | 2007.08.20 |
페이지 수정시 메뉴들 가지런히 놓이게 하기 [3] | 팔공산 | 2007.08.21 |
layout skin 제작시 info.xml도 잘 보세요 [1] | 바람처럼.. | 2007.08.21 |
zbxe 일주일 사용기 및 팁 [1] | 팔공산 | 2007.08.21 |
홈페이지 주소 고정시키기 [12] | :에반: | 2007.08.21 |
로고 위치 변경하기 [4] | 김영훈715 | 2007.08.21 |
설치환경을 갖추어도 설치시 문제 [1] | 하얀후니 | 2007.08.22 |
rewrite mod 설정, 해지 [1] | 아름드리479 | 2007.08.22 |
(회원가입) 닉네임 필요없이 이름만 입력 받으려면 [16] | Simulz | 2007.08.22 |
Zbxe 서버 이전하기 [4] | 팔공산 | 2007.08.22 |