diff --git a/app/Filament/Resources/Entries/Schemas/EntryForm.php b/app/Filament/Resources/Entries/Schemas/EntryForm.php
index 41c94e5..a0613d3 100644
--- a/app/Filament/Resources/Entries/Schemas/EntryForm.php
+++ b/app/Filament/Resources/Entries/Schemas/EntryForm.php
@@ -36,7 +36,56 @@ class EntryForm
->collection('featured-image')
->image()
->imageEditor()
- ->columnSpanFull(),
+ ->columnSpanFull()
+ ->hintAction(
+ Action::make('featured_picker')
+ ->label('Pick from Gallery')
+ ->icon('heroicon-m-photo')
+ ->schema([
+ Select::make('image_id')
+ ->label('Select an existing image')
+ ->allowHtml()
+ ->options(function () {
+ return Media::latest()
+ ->get()
+ ->mapWithKeys(function (Media $item) {
+ $url = $item->getUrl();
+
+ $fileName = e($item->file_name);
+ $name = e($item->name ?? '');
+
+ $html = "
".
+ "

".
+ "
{$name} — {$fileName} ";
+
+ return [$item->id => $html];
+ })->toArray();
+ })
+ ->searchable()
+ ->required(),
+ ])
+ ->action(function (array $data, SpatieMediaLibraryFileUpload $component) {
+ $record = $component->getRecord();
+
+ if ($record && $mediaItem = Media::find($data['image_id'])) {
+ // Clear any existing featured image
+ $record->clearMediaCollection('featured-image');
+
+ // Get the full path to the media file
+ $fullPath = $mediaItem->getPath();
+
+ // Add a copy of the media file to the featured-image collection
+ $record->addMedia($fullPath)
+ ->usingName($mediaItem->name ?: $mediaItem->file_name)
+ ->usingFileName($mediaItem->file_name)
+ ->preservingOriginal()
+ ->toMediaCollection('featured-image');
+
+ // Refresh the page to show the new featured image
+ $component->getLivewire()->dispatch('$refresh');
+ }
+ })
+ ),
Toggle::make('is_published')
->required(),
Toggle::make('is_featured')