/laravel-medialibrary-ext

Extra features for spatie/laravel-medialibrary package

Primary LanguagePHPMIT LicenseMIT

Extra features for spatie/laravel-medialibrary package

Source Code Latest Version Total Downloads License: MIT Build Status Quality Score

This package provides extra features built on top of the spatie/laravel-medialibrary package.

Compatibility

The extension package will follow the original package compatibilities and upgrades.
However, the minor and patch version numbers may differ, according to the feature additions or bug fixes required by this package.

Documentation

Find the complete package documentation here : https://docs.spatie.be/laravel-medialibrary/v7.

Installation

This extension package is a fork from the original spatie/laravel-medialibrary one.
As so, you should uninstall the original package if you installed it to avoid conflicts :

composer remove spatie/laravel-medialibrary

Then, install the extension package via composer :

composer require "okipa/laravel-medialibrary-ext:^7.0"

Follow the original package installation instructions :

Finally, you can publish the extension translation files if needed with :

php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="translations"

Extra features

Cache busting

Image name versioning

This feature is now part of the original package.

Constraints

Collection mime types constraint setup

This feature is now part of the original package.

Collection validation constraints rules generation

Declare your media validation constraints in a breeze with validationConstraints(string $collectionName): string.

// in your user storing form request for example
public function rules()
{
    return [
        'avatar' => (new User)->validationConstraints('avatar'),
        // your other validation rules
    ];
}
// rendering example : `dimensions:min_width=60,min_height=20|mimetypes:image/jpeg,image/png`

Collection validation constraints legend generation

Easily add legends under your media inputs with constraintsLegend(string $collectionName): string.

<!-- in your HTML form -->
<label for="avatar">Choose a profile picture :</label>
<input type=" id="avatar" name="avatar" value="{{ $avatarFileName }}">
<small>{{ (new User)->constraintsLegend('avatar') }}</small>
<!-- Rendering example : `Min. width : 150 px / Min. height : 70 px. Accepted MIME Type(s) : image/jpeg, image/png.` -->

Global conversions queued status

Manage the global conversions queued status by setting a boolean value to MEDIALIBRARY_QUEUED_CONVERSIONS in your.env file, or directly to config('medialibrary.queued_conversions') if you published the package config file.
This will set the default queued status for all your defined conversions.
You still will be able to manually define a specific queued status for a conversion.

Testing

composer test

Changelog

Please see CHANGELOG for more information about what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.