awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
343 stars 89 forks source link

imageResizeTargetWidth() not working #270

Closed mohdaftab closed 1 year ago

mohdaftab commented 1 year ago

Hello,

I am trying to make Filament Curator resize the images when uploading using imageResizeTargetWidth() as suggested in the documentation. Please see the codes below for AppServiceProvider.php and SliderBlock.php I am using Filament v2.0 and Curator v2.8

`class AppServiceProvider extends ServiceProvider { /**

`<?php

namespace App\Filament\Fabricator\PageBlocks;

use Awcodes\Curator\Components\Forms\CuratorPicker; use Filament\Forms\Components\Builder\Block; use Filament\Forms\Components\Repeater; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Z3d0X\FilamentFabricator\PageBlocks\PageBlock;

class SliderBlock extends PageBlock { public static function getBlockSchema(): Block { return Block::make('slider') ->schema([ Repeater::make("slider") ->schema([ TextInput::make('title')->required(), Textarea::make('description')->nullable(), TextInput::make('link_text')->requiredWith('link'), TextInput::make('link')->url()->requiredWith('link_text'), CuratorPicker::make('photo') ->imageResizeTargetWidth(500) ->required(), ]) ->grid(2) ->defaultItems(1) ->collapsible() ->required(), ]); }

public static function mutateData(array $data): array
{
    return $data;
}

} `

The image is uploaded as with the same resolution as original and it doesn't resize. Also I would like to convert all png and jpg photos to webp format on upload.

Please let me know how to fix this?

Thank you

awcodes commented 1 year ago

I believe you have to also use ->imageResizeMode() in order for the image resize methods to work. Have a look at the Filament docs for FileUpload.

mohdaftab commented 1 year ago

Thank you so much.

ahmetkocabiyik commented 4 months ago

I have same problem with Filament V3.2 and Curator V3.6. I have also added imageResizeMode but nothing change. My form component like below. Is there anything wrong ?

CuratorPicker::make('cover_id')
                    ->label("Cover")
                    ->pathGenerator(DatePathGenerator::class)
                    ->size('sm')
                    ->imageResizeMode('cover')
                    ->imageResizeTargetWidth('1920')
                    ->imageResizeTargetHeight('1080')
                    ->relationship('cover', 'id')