From 09db21f911b878498f8de8a7798a359c24ba116b Mon Sep 17 00:00:00 2001 From: daurensky Date: Tue, 19 Mar 2024 13:45:43 +0500 Subject: [PATCH] feat: add image optimizer --- composer.json | 3 ++- src/UI/Filament/Resources/ProductResource.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 7821857..070e7e6 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "spatie/laravel-data": "^3.2", "spatie/laravel-json-api-paginate": "^1.13", "spatie/laravel-query-builder": "^5.7", - "spatie/laravel-translatable": "^6.5" + "spatie/laravel-translatable": "^6.5", + "joshembling/image-optimizer": "^1.4" }, "require-dev": { "laravel/pint": "^1.0", diff --git a/src/UI/Filament/Resources/ProductResource.php b/src/UI/Filament/Resources/ProductResource.php index a167b5e..c5e893a 100644 --- a/src/UI/Filament/Resources/ProductResource.php +++ b/src/UI/Filament/Resources/ProductResource.php @@ -23,7 +23,10 @@ public static function form(Forms\Form $form): Forms\Form Forms\Components\SpatieMediaLibraryFileUpload::make('photo') ->label(__('admin-kit-products::products.resource.photo')) ->collection('photo') - ->required(), + ->image() + ->required() + ->optimize('webp') + ->resize(30), TranslatableTabs::make(fn ($locale) => Tab::make($locale)->schema([ Forms\Components\TextInput::make('title.'.$locale) ->label(__('admin-kit-products::products.resource.name')) @@ -34,7 +37,10 @@ public static function form(Forms\Form $form): Forms\Form Forms\Components\SpatieMediaLibraryFileUpload::make('attachments.'.$locale) ->label(__('admin-kit-products::products.resource.attachments')) ->collection('attachments.'.$locale) - ->multiple(), + ->multiple() + ->image() + ->optimize('webp') + ->resize(30), ])), ]) ->columns(1);