Filament Plugins

Purchase

File info

When selecting an item from the Media Library, the file info panel appears. This panel contains the most important information about the selected media item. Depending on the driver, there is also the ability to edit meta data relating to the image.

File info

Tags

If you are using the Media Library Item Driver and have spatie/laravel-tags installed, the Media Library will automatically show a tags input in the file info panel. This allows you to easily add or remove tags from the selected media item.

Disabling automatic tags integration

If you would like to disable the automatic tags integration, you can pass false to the ->spatieTagsIntegration() method:

php

$plugin->spatieTagsIntegration(false)

File info edit

The File info panel also allows you to edit metadata relating to the selected media item. For the MediaLibraryItemDriver, this includes an automatically provided edit form for editing the media item's caption and alt-text.

To define a custom file info edit form, follow the steps below:

1

Components

First, you need to define the components that will be used in the file info edit form. You can do this by using the ->fileInfoEditComponents() method on the driver.

php

$driver
    ->fileInfoEditComponents([
        TextInput::make('sku')
            ->label('SKU')
            ->rules(['string', 'max:255']),
    ])
2

Hydrating the form

Next, you need to hydrate the form with the existing data from the file. You can do this by using the ->hydrateFileInfoEditUsing() method on the driver.

php

$driver
    ->hydrateFileInfoEditUsing(function (Concerns\FileData $file) {
        // Return an array with the field's values based on `$file`...
        return [
            'sku' => ...,
        ];
    })
3

Saving the form

Next, you need to hydrate the form with the existing data from the file. You can do this by using the ->hydrateFileInfoEditUsing() method on the driver.

php

$driver
    ->saveFileInfoEditUsing(function (Concerns\FileData $file, array $data) {
        // Save the `$data` somewhere to retrieve it later...
    });

This way, the provided captions show up in the file info edit form and they will be hydrated and saved correctly.

© FilamentPlugins.com ✦ 2022 – 2025 ✦ All rights reserved.