mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-15 10:04:13 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
3391108551
|
@ -842,7 +842,7 @@ class Helper
|
|||
$filetype = @finfo_file($finfo, $file);
|
||||
finfo_close($finfo);
|
||||
|
||||
if (($filetype == 'image/jpeg') || ($filetype == 'image/jpg') || ($filetype == 'image/png') || ($filetype == 'image/bmp') || ($filetype == 'image/gif')) {
|
||||
if (($filetype == 'image/jpeg') || ($filetype == 'image/jpg') || ($filetype == 'image/png') || ($filetype == 'image/bmp') || ($filetype == 'image/gif') || ($filetype == 'image/avif')) {
|
||||
return $filetype;
|
||||
}
|
||||
|
||||
|
@ -1106,6 +1106,8 @@ class Helper
|
|||
'jpeg' => 'far fa-image',
|
||||
'gif' => 'far fa-image',
|
||||
'png' => 'far fa-image',
|
||||
'webp' => 'far fa-image',
|
||||
'avif' => 'far fa-image',
|
||||
// word
|
||||
'doc' => 'far fa-file-word',
|
||||
'docx' => 'far fa-file-word',
|
||||
|
@ -1141,6 +1143,8 @@ class Helper
|
|||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'png':
|
||||
case 'webp':
|
||||
case 'avif':
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -34,8 +34,8 @@ class ImageUploadRequest extends Request
|
|||
{
|
||||
|
||||
return [
|
||||
'image' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp',
|
||||
'avatar' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp',
|
||||
'image' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp,avif',
|
||||
'avatar' => 'mimes:png,gif,jpg,jpeg,svg,bmp,svg+xml,webp,avif',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -103,15 +103,13 @@ class ImageUploadRequest extends Request
|
|||
\Log::info('File name will be: '.$file_name);
|
||||
\Log::debug('File extension is: '.$ext);
|
||||
|
||||
if ($image->getMimeType() == 'image/webp') {
|
||||
// If the file is a webp, we need to just move it since webp support
|
||||
if (($image->getMimeType() == 'image/avif') || ($image->getMimeType() == 'image/webp')) {
|
||||
// If the file is a webp or avif, we need to just move it since webp support
|
||||
// needs to be compiled into gd for resizing to be available
|
||||
|
||||
\Log::debug('This is a webp, just move it');
|
||||
Storage::disk('public')->put($path.'/'.$file_name, file_get_contents($image));
|
||||
|
||||
} elseif($image->getMimeType() == 'image/svg+xml') {
|
||||
// If the file is an SVG, we need to clean it and NOT encode it
|
||||
\Log::debug('This is an SVG');
|
||||
$sanitizer = new Sanitizer();
|
||||
$dirtySVG = file_get_contents($image->getRealPath());
|
||||
$cleanSVG = $sanitizer->sanitize($dirtySVG);
|
||||
|
@ -123,9 +121,6 @@ class ImageUploadRequest extends Request
|
|||
}
|
||||
} else {
|
||||
|
||||
\Log::debug('Not an SVG or webp - resize');
|
||||
\Log::debug('Trying to upload to: '.$path.'/'.$file_name);
|
||||
|
||||
try {
|
||||
$upload = Image::make($image->getRealPath())->setFileInfoFromPath($image->getRealPath())->resize(null, $w, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
|
@ -147,10 +142,8 @@ class ImageUploadRequest extends Request
|
|||
|
||||
// Remove Current image if exists
|
||||
if (($item->{$form_fieldname}!='') && (Storage::disk('public')->exists($path.'/'.$item->{$db_fieldname}))) {
|
||||
\Log::debug('A file already exists that we are replacing - we should delete the old one.');
|
||||
try {
|
||||
Storage::disk('public')->delete($path.'/'.$item->{$form_fieldname});
|
||||
\Log::debug('Old file '.$path.'/'.$file_name.' has been deleted.');
|
||||
} catch (\Exception $e) {
|
||||
\Log::debug('Could not delete old file. '.$path.'/'.$file_name.' does not exist?');
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class UploadFileRequest extends Request
|
|||
$max_file_size = \App\Helpers\Helper::file_upload_max_size();
|
||||
|
||||
return [
|
||||
'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,json,webp|max:'.$max_file_size,
|
||||
'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,json,webp,avif|max:'.$max_file_size,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
return newParams;
|
||||
},
|
||||
formatLoadingMessage: function () {
|
||||
return '<h2><i class="fas fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('general.loading') }} </h4>';
|
||||
return '<h2><i class="fas fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('general.loading') }} </h2>';
|
||||
},
|
||||
icons: {
|
||||
advancedSearchIcon: 'fas fa-search-plus',
|
||||
|
@ -86,7 +86,6 @@
|
|||
clearSearch: 'fa-times'
|
||||
},
|
||||
exportOptions: export_options,
|
||||
|
||||
exportTypes: ['xlsx', 'excel', 'csv', 'pdf','json', 'xml', 'txt', 'sql', 'doc' ],
|
||||
onLoadSuccess: function () {
|
||||
$('[data-tooltip="true"]').tooltip(); // Needed to attach tooltips after ajax call
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
<label class="btn btn-default" aria-hidden="true">
|
||||
{{ trans('button.select_file') }}
|
||||
<input type="file" name="{{ (isset($fieldname) ? $fieldname : 'image') }}" class="js-uploadFile" id="uploadFile" data-maxsize="{{ Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/webp,image/png,image/svg,image/svg+xml" style="display:none; max-width: 90%" aria-label="{{ (isset($fieldname) ? $fieldname : 'image') }}" aria-hidden="true">
|
||||
<input type="file" name="{{ (isset($fieldname) ? $fieldname : 'image') }}" class="js-uploadFile" id="uploadFile" data-maxsize="{{ Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/webp,image/png,image/svg,image/svg+xml,image/avif" style="display:none; max-width: 90%" aria-label="{{ (isset($fieldname) ? $fieldname : 'image') }}" aria-hidden="true">
|
||||
</label>
|
||||
<span class='label label-default' id="uploadFile-info"></span>
|
||||
|
||||
|
|
Loading…
Reference in a new issue