finnwiel/shazzoo-media

A Laravel + Filament plugin extension for filament-curator. That adds conversions and new views.

v1.0.6 2025-05-09 10:02 UTC

This package is auto-updated.

Last update: 2025-05-09 10:03:27 UTC


README

License Packagist Version Laravel Filament PHP

A Laravel + Filament plugin that extends Filament Curator with custom media conversion logic and a customized media model.

Installation

You can install the package via composer then run the installation command:

composer require finnwiel/shazzoo-media

If you installed Curator before Shazzoo Media, you’ll need to remove Curator’s media table migration manually before running the install command.

php artisan shazzoo_media:install

Note: This package will install curator for you but you will have to do some of the setup. Like installing CropperJS and using a custom filament theme for styling. If you have not set up a custom theme and are using a Panel follow the instructions in the Filament Docs first.

npm install -D cropperjs

Import the plugin's stylesheet and cropperjs' stylesheet into your theme's css file.

@import '<path-to-vendor>/awcodes/filament-curator/resources/css/plugin.css';

Add the plugin's views to your tailwind.config.js file.

content: [
        './vendor/awcodes/filament-curator/resources/**/*.blade.php',
        './vendor/finnwiel/shazzoo-media/resources/views/vendor/curator/components/**/*.blade.php',
]

Usage

Global settings

The plugins settings can be managed through the config file

php artisan vendor:publish --tag=shazzoo_media-config

Note: This package will also change some of curators settings, you can still manage curators setting but they may not work with Shazzoo Media

Filament Panels

If you are using Filament Panels you will need to add the Plugin to your Panel's configuration. This will register the plugin's resources with the Panel. All methods are optional, and will be read from the config file if not provided.

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
                \Awcodes\Curator\CuratorPlugin::make()
                    ->label('Media')
                    ->navigationLabel('Media Library')
                    ->registerNavigation(true)
                    ->navigationCountBadge(true)   
            ])
}

Picker field

Shazzoo Media adds a conversions method to the picker field, this method accepts an array. The conversions will subsequently be set in the database for each array item. Shazzoo Media will also create the conversion image.

ShazzooMediaCuratorPicker::make('featured_image_id')
                    ->conversions(['thumbnail']),

To generate actually set the conversions in the database you need to add a trait to the create and edit classes of your resource.

use FinnWiel\ShazzooMedia\Traits\HandlesConversions;

class CreatePost extends CreateRecord
{
    use HandlesConversions;

    protected static string $resource = PostResource::class;
}

Policies

The package uses a policy for actions relating to the media library. This policy is used by default, but can be disabled by setting media_policies to false in the config file.

If you do want to keep using the media policy you need to add the HasRoleCheck trait to the User model.

use FinnWiel\ShazzooMedia\Traits\HasRoleCheck;

The policy uses these roles:

Role Permissions
Viewer View
Editor View Edit
Admin View Edit Upload
Super Admin All actions for all tenant_id's

The Shazzoo Media plugin also uses a tenant_id any media uploaded by a user will automatically have the same tenant_id as the user. This way only users with the same tenancy can see the media. Other roles will still apply.

If you do not want to functionality simply set the enable_tenant_scope to false in the config file. This will make sure all tenancy checks are skipped. The tenant_id for media items will still be set to the tenant_id of the user that uploaded. This makes it possible to toggle this option later.

Conversions

Conversions are set in config/shazzoo_media.php in the conversions array. To add or remove conversions change the array with the same structure.

'conversions' => [
    'profile' => ['width' => 80,'height' => 80],
    'thumbnail' => ['width' => 200,'height' => 200],
    'medium' => ['width' => 400,'height' => 400],
    'large' => ['width' => 600,'height' => 600],
],

So adding a new conversion called small would look like this:

'conversions' => [
    'profile' => ['width' => 80,'height' => 80],
    'thumbnail' => ['width' => 200,'height' => 200],
    'medium' => ['width' => 400,'height' => 400],
    'large' => ['width' => 600,'height' => 600],
    'small' => ['width' => 100,'height' => 100],
],