mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-06 12:02:45 +03:00
Cleaned up logic within ImageRepo
- Moved out extension check to ImageService as that seems more relevant. - Updated models to use static-style references instead of facade to align with common modern usage within the app. - Updated custom image_extension validation rule to use shared logic in image service.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace BookStack\Providers;
|
||||
|
||||
use BookStack\Uploads\ImageService;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -13,9 +14,8 @@ class CustomValidationServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
|
||||
$validImageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
|
||||
|
||||
return in_array(strtolower($value->getClientOriginalExtension()), $validImageExtensions);
|
||||
$extension = strtolower($value->getClientOriginalExtension());
|
||||
return ImageService::isExtensionSupported($extension);
|
||||
});
|
||||
|
||||
Validator::extend('safe_url', function ($attribute, $value, $parameters, $validator) {
|
||||
|
Reference in New Issue
Block a user