1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

show default image icon for large image files

This commit is contained in:
Damodar Lohani 2022-02-16 10:04:49 +00:00
parent 3da9b8ffae
commit 193426e34b
2 changed files with 10 additions and 6 deletions

View file

@ -2,6 +2,7 @@
return [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554
'default' => __DIR__.'/logos/none.png',
'default_image' => __DIR__.'/logos/image.png',
// Video Files
'video/mp4' => __DIR__.'/logos/video.png',

View file

@ -909,18 +909,20 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
throw new Exception('File not found', 404);
}
if($file->getAttribute('sizeActual') > APP_LIMIT_PREVIEW) {
throw new Exception('Preview not supported for file above ' . Storage::human(APP_LIMIT_PREVIEW) . ' in size.', 400);
}
$path = $file->getAttribute('path');
$type = \strtolower(\pathinfo($path, PATHINFO_EXTENSION));
$algorithm = $file->getAttribute('algorithm');
$cipher = $file->getAttribute('openSSLCipher');
$mime = $file->getAttribute('mimeType');
if (!\in_array($mime, $inputs)) {
$path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default'];
if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > APP_LIMIT_PREVIEW) {
if(!\in_array($mime, $inputs)) {
$path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default'];
} else {
// it was an image but the file size exceeded the limit
$path = $fileLogos['default_image'];
}
$algorithm = null;
$cipher = null;
$background = (empty($background)) ? 'eceff1' : $background;
@ -928,6 +930,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
$key = \md5($path . $width . $height . $gravity . $quality . $borderWidth . $borderColor . $borderRadius . $opacity . $rotation . $background . $output);
}
$compressor = new GZIP();
if (!$deviceFiles->exists($path)) {