Filament Plugins

Purchase

Media Column

In order to display items from the Media Library into a Filament table, the package provides a custom Filament table column called MediaColumn. This column can be used in any Filament table, both inside or outside a Filament panel.

Using the column

You can include the column like this:

php

MediaColumn::make('thumbnail_id')
    ->label('Thumbnail')

All methods available on the ImageColumn class are also available on the MediaColumn class:

php

MediaColumn::make('thumbnail_id')
    ->label('Thumbnail')
    ->circular()
    ->size()

Depending on which driver you are using, you will need to provide either the id of the MediaLibraryItem (if you are using the medialibrary driver) or the file path (if you are using the filesystem driver).

Relationship

If you are using the MediaLibraryItem driver, it is more efficient to load the related MediaLibraryItem using a relationship. You can do this by specifying the relationship name and using the ->relationship() method:

php

MediaColumn::make('featuredImage')
    ->relationship()
    ->label('Featured image')

This will eager load the related MediaLibraryItem and prevent N+1 query issues.

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