Download the PHP package finnwiel/shazzoo-media without Composer
On this page you can find all versions of the php package finnwiel/shazzoo-media. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package shazzoo-media
Shazzoo Media
A Laravel + Filament plugin that extends Filament Curator with custom media conversion logic and a customized media model.
- Installation
- Usage
- Global Settings
- Filament Panels
- Picker Field
- Conversions
Installation
⚠️ Important: Before installing, make sure the GD extension is enabled in your php.ini. Without it, image conversions will fail and no thumbnails will be generated.
You can install the package via composer then run the installation command:
If you installed Curator before Shazzoo Media, you’ll need to remove Curator’s media table migration manually before running the install command.
Note: This plugin will install Curator for you, but you still need to set up your Filament panel theme.
Import Curator's stylesheet in your Filament panel theme CSS file.
Add Curator and Shazzoo Media views to your theme sources.
Usage
Global settings
The plugins settings can be managed through the config file
Note: This plugin will also change some of curators settings, you can still manage curators setting but they may not work with Shazzoo Media
To publish the plugins Model run:
Important: When publishing the model make sure to also change the model in the config.
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.
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.
The picker also has a fileType method, this accepts the following strings: 'image', 'icon', 'document'.
| Commands | Tags |
|---|---|
image |
jpeg png, webp, gif |
icon |
svg |
document |
pdf docx |
To generate actually set the conversions in the database you need to add a trait to the create and edit classes of your resource.
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.
So adding a new conversion called small would look like this:
As you can see the existing conversions can also be edited, this can even be done when some conversions have already been made. Just be sure to run the php artisan media:conversions:regenerate command. This will regenerate the conversions to the new sizes.
Showing images
To show images in your frontend using the ShazzooMedia model, you can leverage the built-in dynamic URL accessors for media conversions.
For each image conversion defined in your config (shazzoo_media.conversions), a dynamic property is available on your media model:
If the conversion file exists, it returns the converted image URL. If not, it gracefully falls back to the original image URL.
Example in blade:
Defining relationships
You are responsible for defining the relationship between your Eloquent models and the media records.
One-to-One Example:
For a model that has a single media item, like a Post with a featured image:
Usage:
One-to-Many Example:
For a model that has multiple images, like a Product with a gallery:
Usage:
Artisan commands
| The Shazzoo Media plugin uses some artisan commands. | Commands | Tags | Uses |
|---|---|---|---|
media:clear |
- | Clears your image files from the storage folder. | |
media:clear-conversions |
- | Clears your image conversion files from the storage folder. | |
media:conversions:clear-db |
id |
Clears conversion(s) in the database. | |
media:conversions:set-db |
id append |
Sets conversion(s) in the databse. | |
media:conversions:generate |
id all only |
Generates the conversions for the images. | |
media:conversions:regenerate |
id only |
Regenerates the conversions for the images. | |
media:conversions:list |
- | Lists out all image conversions |
Policies & Tenancy
Policies
The Shazzoo Media library doesn't use a policy by default but lets you publish a policy template.
This will publish a policy file to App/Policies/MediaPolicy.php the policy should be registered automatically by the plugin. The published file will be a blank policy, you will need to add your own rules. Also make sure that media_policies is set to true in the config/shazzoo_media.php.
Tenancy
This package does not implement tenancy or user-based access control out of the box.
If your application requires scoping media by tenant, team, or user, you are responsible for applying your own global scope to the ShazzooMedia model. This can be done by publishing the model and implementing it there, or you can add the global scope in the AppServiceProvider.php's boot function.
All versions of shazzoo-media with dependencies
illuminate/support Version ^11.0 || ^12.0 || ^13.0
intervention/image Version ^3.9
livewire/livewire Version ^4.1
filament/filament Version ^5.0
awcodes/filament-curator Version ^5.0
spatie/laravel-package-tools Version ^1.0