저자: XE Developers (developers@xpressengine.com)
상속: extends Media
 /**
  * get file's source
  *
  * @param string $url url
  * @param string $id  id
  *
  * @return void
  */
 public function fileSource($url, $id)
 {
     $file = File::find($id);
     /** @var \Xpressengine\Media\MediaManager $mediaManager */
     $mediaManager = \App::make('xe.media');
     if ($mediaManager->is($file) === true) {
         $dimension = 'L';
         if (\Agent::isMobile() === true) {
             $dimension = 'M';
         }
         $media = Image::getThumbnail($mediaManager->make($file), PageModule::THUMBNAIL_TYPE, $dimension);
     }
     header('Content-type: ' . $media->mime);
     echo $media->getContent();
 }
예제 #2
0
 protected static function bindGalleryThumb($item)
 {
     /** @var \Xpressengine\Media\MediaManager $mediaManager */
     $mediaManager = \App::make('xe.media');
     // board gallery thumbnails 에 항목이 없는 경우
     if ($item->boardThumbnailFileId === null && $item->boardThumbnailPath === null) {
         // find file by document id
         $files = File::getByFileable($item->id);
         $fileId = '';
         $externalPath = '';
         $thumbnailPath = '';
         if (count($files) == 0) {
             // find file by contents link or path
             $externalPath = static::getImagePathFromContent($item->content);
             // make thumbnail
             $thumbnailPath = $externalPath;
         } else {
             foreach ($files as $file) {
                 if ($mediaManager->is($file) !== true) {
                     continue;
                 }
                 // 어떤 크기의 썸네일을 사용할 것인지 스킨 설정을 통해 결정(두배 이미지가 좋다함)
                 $dimension = 'L';
                 $media = Image::getThumbnail($mediaManager->make($file), BoardModule::THUMBNAIL_TYPE, $dimension);
                 if ($media === null) {
                     continue;
                 }
                 $fileId = $file->id;
                 $thumbnailPath = $media->url();
                 break;
             }
         }
         $item->boardThumbnailFileId = $fileId;
         $item->boardThumbnailExternalPath = $externalPath;
         $item->boardThumbnailPath = $thumbnailPath;
         $model = new BoardGalleryThumb();
         $model->fill(['targetId' => $item->id, 'boardThumbnailFileId' => $fileId, 'boardThumbnailExternalPath' => $externalPath, 'boardThumbnailPath' => $thumbnailPath]);
         $model->save();
     }
     // 없을 경우 출력될 디폴트 이미지 (스킨의 설정으로 뺄 수 있을것 같음)
     if ($item->boardThumbnailPath == '') {
         $item->boardThumbnailPath = 'http://placehold.it/300x200';
     }
 }
예제 #3
0
 /**
  * Extract file meta data
  *
  * @param Image $image file instance
  * @return array
  */
 protected function extractDimension(Image $image)
 {
     return getimagesizefromstring($image->getContent());
 }
 /**
  * get file source
  *
  * @param EditorHandler $handler    editor handler
  * @param string        $instanceId instance id
  * @param string        $id         document id
  * @return void
  * @throws InvalidArgumentException
  */
 public function fileSource(EditorHandler $handler, $instanceId, $id)
 {
     if (empty($id)) {
         throw new InvalidArgumentException();
     }
     $file = File::find($id);
     /** @var \Xpressengine\Media\MediaManager $mediaManager */
     $mediaManager = app('xe.media');
     if ($mediaManager->is($file) === true) {
         $dimension = 'L';
         if (\Agent::isMobile() === true) {
             $dimension = 'M';
         }
         $media = Image::getThumbnail($mediaManager->make($file), EditorHandler::THUMBNAIL_TYPE, $dimension);
         header('Content-type: ' . $media->mime);
         echo $media->getContent();
     }
 }