mime_type); switch ($type) { case 'image': // try to check if file have thumbnail if (file_exists(config('app.thumbnail_url') . '/' . $file->filename)) { $url = config('app.thumbnail_url') . '/' . $file->filename; } else { $url = config('app.upload_url') . '/' . $file->filename; } return '' . $file->description . ''; break; case 'text': return ''; break; case 'application': switch ($subtype) { case 'pdf': return ''; break; default: return ''; break; } break; default: return ''; break; } } /** * * * @param File $file * * @return string */ public static function getFormattedSize(File $file) { $bytes = $file->file_size; $label = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; for ($i = 0; $bytes >= 1024 && $i < (count($label) - 1); $bytes /= 1024, $i++) { ; } return (round($bytes, 2) . " " . $label[$i]); } /** * Get preview for file detail * * @param File $file * * @return \Illuminate\Contracts\Routing\UrlGenerator|string */ public static function getLargePreview(File $file) { list($type, $subtype) = explode('/', $file->mime_type); $url = config('app.upload_url') . '/' . $file->filename; $path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->filename; switch ($type) { case 'image': return '' . $file->description . ''; break; case 'text': $string = '
';
                $string .= htmlspecialchars(file_get_contents($path));
                $string .= '
'; return $string; break; case 'application': switch ($subtype) { case 'pdf': return ''; break; default: return ''; break; } break; default: return self::getPreview($file); break; } } /** * @param File $file * * @return array */ public static function getAdditionalInfo(File $file) { list($type, $subtype) = explode('/', $file->mime_type); $path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->filename; switch ($type) { case 'text': return [ trans('admin/fileManager.encoding') => mb_detect_encoding(file_get_contents($path)) ]; break; case 'image': list ($width, $height) = getimagesize($path); return [ trans('admin/fileManager.resolution') => $height . ' x ' . $width, ]; break; } return []; } }