Beispiel #1
0
 /**
  * Retrieves the thumbnail to send back to the browser
  *
  * The thumbnail is either a resized preview of the file or the original file
  * Thumbnails are base64encoded before getting sent back
  *
  *
  * @param int $fileId the ID of the file of which we need a thumbnail preview of
  * @param bool $square whether the thumbnail should be square
  * @param double $scale whether we're allowed to scale the preview up
  *
  * @return array<string,array|string>
  */
 private function getThumbnail($fileId, $square, $scale)
 {
     list($width, $height, $aspect, $animatedPreview, $base64Encode) = $this->thumbnailService->getThumbnailSpecs($square, $scale);
     /** @type File $file */
     list($file, $preview, $status, $type) = $this->getData($fileId, $width, $height, $aspect, $animatedPreview, $base64Encode);
     if ($preview === null) {
         $preview = $this->prepareEmptyThumbnail($file, $status);
     } else {
         if ($type === 'preview') {
             $preview['preview'] = $this->previewService->previewValidator($square, $base64Encode);
         }
     }
     return [$preview, $status];
 }
Beispiel #2
0
 /**
  * Retrieves the thumbnail to send back to the browser
  *
  * The thumbnail is either a resized preview of the file or the original file
  * Thumbnails are base64encoded before getting sent back
  *
  *
  * @param int $fileId the ID of the file of which we need a thumbnail preview of
  * @param bool $square whether the thumbnail should be square
  * @param double $scale whether we're allowed to scale the preview up
  *
  * @return array<string,array|string>
  */
 private function getThumbnail($fileId, $square, $scale)
 {
     list($width, $height, $aspect, $animatedPreview, $base64Encode) = $this->thumbnailService->getThumbnailSpecs($square, $scale);
     /** @type File $file */
     list($file, $preview, $status, $type) = $this->getData($fileId, $width, $height, $aspect, $animatedPreview, $base64Encode);
     if ($preview === null) {
         if ($status !== Http::STATUS_NOT_FOUND) {
             $preview = ['preview' => null, 'mimetype' => $file->getMimeType()];
         }
     } else {
         if ($type === 'preview') {
             $preview['preview'] = $this->previewService->previewValidator($square, $base64Encode);
         }
     }
     return [$preview, $status];
 }
 private function mockGetThumbnailSpecs($square, $scale, $array)
 {
     $this->thumbnailService->expects($this->once())->method('getThumbnailSpecs')->with($square, $scale)->willReturn($array);
 }