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 '';
break;
case 'text':
return self::getIcon($file, 'fa-file-text-o');
break;
case 'application':
switch ($subtype) {
case 'pdf':
return self::getIcon($file, 'fa-file-pdf-o');
break;
default:
return self::getIcon($file, 'fa-newspaper-o');
break;
}
break;
default:
return self::getIcon($file, 'fa-question');
break;
}
}
/**
* Shortcut for displaying icons
*
* @param $file
* @param $icon
*
* @return string
*/
protected static function getIcon($file, $icon)
{
return '
' . e(str_limit($file->original_filename, 15)) . '
';
$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 [];
}
}