1111use Filament \Actions \Action ;
1212use Filament \Facades \Filament ;
1313use Filament \Forms \Components \Select ;
14+ use Filament \Forms \Components \TextInput ;
1415use Filament \Forms \Components \Toggle ;
1516use Filament \Schemas \Components \Grid ;
1617use Filament \Schemas \Components \Tabs ;
@@ -29,6 +30,8 @@ public static function getDefaultConfig(): array
2930 'multiple ' => false ,
3031 'imagesOnly ' => false ,
3132 'withMetadata ' => true ,
33+ 'cropPreset ' => '' ,
34+ 'acceptedFileTypes ' => null ,
3235 ];
3336 }
3437
@@ -81,7 +84,12 @@ public static function make(string $name, Field $field): Input
8184 $ input = $ input ->label ($ field ->name ?? self ::getDefaultConfig ()['label ' ] ?? null )
8285 ->uploaderStyle (Style::tryFrom ($ field ->config ['uploaderStyle ' ] ?? null ) ?? Style::tryFrom (self ::getDefaultConfig ()['uploaderStyle ' ]))
8386 ->multiple ($ field ->config ['multiple ' ] ?? self ::getDefaultConfig ()['multiple ' ])
84- ->withMetadata ($ field ->config ['withMetadata ' ] ?? self ::getDefaultConfig ()['withMetadata ' ]);
87+ ->withMetadata ($ field ->config ['withMetadata ' ] ?? self ::getDefaultConfig ()['withMetadata ' ])
88+ ->cropPreset ($ field ->config ['cropPreset ' ] ?? self ::getDefaultConfig ()['cropPreset ' ]);
89+
90+ if ($ field ->config ['acceptedFileTypes ' ] ?? self ::getDefaultConfig ()['acceptedFileTypes ' ]) {
91+ $ input ->acceptedFileTypes (explode (', ' , $ field ->config ['acceptedFileTypes ' ]));
92+ }
8593
8694 if ($ field ->config ['imagesOnly ' ] ?? self ::getDefaultConfig ()['imagesOnly ' ]) {
8795 $ input ->imagesOnly ();
@@ -127,6 +135,21 @@ public function getForm(): array
127135 Style::REGULAR ->value => __ ('Regular ' ),
128136 ])
129137 ->required (),
138+ TextInput::make ('config.cropPreset ' )
139+ ->label (__ ('Crop preset ' ))
140+ ->placeholder (__ ('e.g., "free, 1:1, 16:9" or leave empty to disable ' ))
141+ ->helperText (__ ('Comma-separated aspect ratios (e.g., "free, 1:1, 16:9, 4:3") or empty to disable cropping ' ))
142+ ->columnSpanFull (),
143+ Select::make ('config.acceptedFileTypes ' )
144+ ->label (__ ('Accepted file types ' ))
145+ ->options ([
146+ 'image/* ' => __ ('Image ' ),
147+ 'video/* ' => __ ('Video ' ),
148+ 'audio/* ' => __ ('Audio ' ),
149+ 'application/* ' => __ ('Application ' ),
150+ ])
151+ ->multiple ()
152+ ->columnSpanFull (),
130153 ]),
131154 ]),
132155 ])->columnSpanFull (),
0 commit comments