Filament Plugins

Purchase

Extending

Sometimes you need more control over the Media Library page than the plugin's configuration methods provide – for example, to add header widgets, override footer actions, or use Filament's full page API for something project-specific. The cleanest way to do this is to subclass the page and register your custom class with the plugin.

Creating a subclass

Create a new page class that extends RalphJSmit\Filament\MediaLibrary\Filament\Pages\MediaLibrary:

app/Filament/Pages/MediaLibraryPage.php
<?php

namespace App\Filament\Pages;

use RalphJSmit\Filament\MediaLibrary\Filament\Pages\MediaLibrary;

class MediaLibraryPage extends MediaLibrary
{
    protected function getHeaderWidgets(): array
    {
        return [
            // Your custom header widgets here
        ];
    }
}

Registering the subclass

Next, open up your panel provider and pass the class to ->mediaLibraryPage() on the plugin:

app/Providers/Filament/AdminPanelProvider.php
use App\Filament\Pages\MediaLibraryPage;
use RalphJSmit\Filament\MediaLibrary\FilamentMediaLibrary;

$panel->plugin(
    FilamentMediaLibrary::make()
        ->mediaLibraryPage(MediaLibraryPage::class),
);

That's all the wiring you need – the plugin will register your class instead of the default page.

Your subclass already includes the HasPageConfiguration trait from the base page. This trait proxies every navigation and configuration call – ->navigationLabel(), ->navigationGroup(), ->navigationIcon(), ->slug(), and so on – through the plugin instance. You don't need to redeclare any of those in your subclass; anything you set on the plugin in your panel provider continues to work exactly as documented in the Navigation page.

If you override a static method like getNavigationIcon() or getNavigationLabel() directly in your subclass, that value will take precedence over whatever the plugin has configured, so only do that intentionally.

© FilamentPlugins.com ✦ 2022 – 2026
PrivacyTerms & Conditions
All rights reserved.