diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 0f3e271756..e3f2b036e0 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -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: diff --git a/app/Http/Requests/ImageUploadRequest.php b/app/Http/Requests/ImageUploadRequest.php index d9947efe7b..25156181e9 100644 --- a/app/Http/Requests/ImageUploadRequest.php +++ b/app/Http/Requests/ImageUploadRequest.php @@ -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?'); } diff --git a/app/Http/Requests/UploadFileRequest.php b/app/Http/Requests/UploadFileRequest.php index 74d33d58eb..ee5624e3d1 100644 --- a/app/Http/Requests/UploadFileRequest.php +++ b/app/Http/Requests/UploadFileRequest.php @@ -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, ]; } diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 430f9566c2..95f2785b61 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -73,7 +73,7 @@ return newParams; }, formatLoadingMessage: function () { - return '