#1331 커버 이미지를 선택할 수 있는 기능 추가

- files 테이블에 cover_image 컬럼 추가
- 썸네일 생성 로직에 cover_image 값을 참조하여 이미지 선택 사용
- 파일 업로드 기능에 UI 추가
This commit is contained in:
bnu 2015-07-07 15:04:06 +09:00
parent cc5207423e
commit 4faa291880
14 changed files with 225 additions and 39 deletions

View file

@ -773,6 +773,12 @@ class documentItem extends Object
{
// Return false if the document doesn't exist
if(!$this->document_srl) return;
if($this->isSecret() && !$this->isGranted())
{
return;
}
// If not specify its height, create a square
if(!$height) $height = $width;
// Return false if neither attachement nor image files in the document
@ -799,27 +805,44 @@ class documentItem extends Object
if(filesize($thumbnail_file)<1) return false;
else return $thumbnail_url;
}
// Target File
$source_file = null;
$is_tmp_file = false;
// 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;
// Find an iamge file among attached files if exists
if($this->hasUploadedFiles())
{
$file_list = $this->getUploadedFiles();
$first_image = null;
foreach($file_list as $file)
{
if($file->direct_download !== 'Y') continue;
if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
{
$source_file = $file->uploaded_filename;
if(!file_exists($source_file)) $source_file = null;
else break;
break;
}
if($first_image) continue;
if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
{
if(file_exists($file->uploaded_filename))
{
$first_image = $file->uploaded_filename;
}
}
}
if(!$source_file && $first_image)
{
$source_file = $first_image;
}
}
// If not exists, file an image file from the content
if(!$source_file)
{