PHPackages                             okipa/laravel-medialibrary-ext - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. okipa/laravel-medialibrary-ext

ActiveLibrary[Image &amp; Media](/categories/media)

okipa/laravel-medialibrary-ext
==============================

Extra features for spatie/laravel-medialibrary package.

10.2.0(3y ago)1011.2k3[1 issues](https://github.com/Okipa/laravel-medialibrary-ext/issues)[1 PRs](https://github.com/Okipa/laravel-medialibrary-ext/pulls)MITPHPPHP 8.1.\*|8.2.\*

Since Apr 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Okipa/laravel-medialibrary-ext)[ Packagist](https://packagist.org/packages/okipa/laravel-medialibrary-ext)[ Docs](https://github.com/okipa/laravel-medialibrary-ext)[ Fund](https://paypal.me/arthurlorent)[ GitHub Sponsors](https://github.com/Okipa)[ RSS](/packages/okipa-laravel-medialibrary-ext/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (10)Versions (270)Used By (0)

[![Laravel Medialibrary Extension](/docs/laravel-medialibrary-ext.png)](/docs/laravel-medialibrary-ext.png)

 [ ![Latest Stable Version](https://camo.githubusercontent.com/6c08ef2c775b2fa2be91f7d96cd9bd0d7c5935a8c37c95b508003a92dbfc7c9f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4f6b6970612f6c61726176656c2d6d656469616c6962726172792d6578742e7376673f7374796c653d666c61742d737175617265) ](https://github.com/Okipa/laravel-medialibrary-ext/releases "Latest Stable Version") [ ![Total Downloads](https://camo.githubusercontent.com/69d0bdf93bfdca719a1a5a3d59f4577effa224a7cd88e186bfc2f51feec71c60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6b6970612f6c61726176656c2d6d656469616c6962726172792d6578742e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/Okipa/laravel-medialibrary-ext "Total Downloads") [ ![Build Status](https://github.com/Okipa/laravel-medialibrary-ext/workflows/CI/badge.svg) ](https://github.com/Okipa/laravel-medialibrary-ext/actions "Build Status") [ ![Coverage Status](https://camo.githubusercontent.com/0da7c561de495b5107e83a72cd22a50d5b18f16835fa294337aa693e4adb9d6e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4f6b6970612f6c61726176656c2d6d656469616c6962726172792d6578742f62616467652e7376673f6272616e63683d6d6173746572) ](https://coveralls.io/github/Okipa/laravel-medialibrary-ext?branch=master "Coverage Status") [ ![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667) ](/LICENSE.md "License: MIT")

This package extension provides extra features for the [spatie/laravel-medialibrary](https://github.com/spatie/laravel-medialibrary) package.

Found this package helpful? Please consider supporting my work!

[![Donate](https://camo.githubusercontent.com/6c3b5a78d466728cacf06baad81fbd1e05af9cdb0406db055d37df429291a74f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275795f6d655f612d4b6f2d2d66692d6666356635662e737667)](https://ko-fi.com/arthurlorent)[![Donate](https://camo.githubusercontent.com/3cd689d69c5219f5c2f2675b7ccccb50061b112100f2468c1cec746765762ebd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174655f6f6e2d50617950616c2d677265656e2e737667)](https://paypal.me/arthurlorent)

Compatibility
-------------

[](#compatibility)

This package extension will follow the [base package](https://github.com/spatie/laravel-medialibrary) major versions but may be a bit stricter about compatibility constraints.

LaravelOriginal packagePHPPackage^9.0 | ^10.0^10.7.98.1.\* | 8.2.\*^10.2^9.0^10.6^8.1 | ^8.2^10.1^9.0^10.0^8.0 | ^8.1^10.0^7.0 | ^8.0^9.0^7.4 | ^8.0^9.1^7.0 | ^8.0^9.0^7.4^9.0^7.0 | ^8.0^8.7.1^7.4^8.1^6.0 | ^7.0^8.0^7.4^8.0^6.0 | ^7.0X^7.4^8.0^5.8 | ^6.0 | ^7.0X^7.2^7.18^5.5 | ^5.6 | ^5.7 | ^5.8 | ^6.0X^7.2^7.12^5.5 | ^5.6 | ^5.7 | ^5.8X^7.2^7.11Upgrade guide
-------------

[](#upgrade-guide)

- [From V9 to V10](/docs/upgrade-guides/from-v9-to-v10.md)
- [From V8 to V9](/docs/upgrade-guides/from-v8-to-v9.md)
- [From V7 to V8](/docs/upgrade-guides/from-v7-to-v8.md)

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Documentation](#documentation)
- [Translations](#translations)
- [Extension features](#extension-features)
    - [Validation rules](#media-validation-rules)
    - [Media caption](#media-caption)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [Licence](#license)

Installation
------------

[](#installation)

First, be sure to follow the base package installation instructions:

-
-

Then, install the extension via composer:

```
composer require okipa/laravel-medialibrary-ext
```

Finally, implement the `ExtendsMediaAbilities` trait to be able to use the extension features in addition of the base package ones.

```
use Illuminate\Database\Eloquent\Model;
use Okipa\MediaLibraryExt\ExtendsMediaAbilities;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Page extends Model implements HasMedia
{
    use InteractsWithMedia;
    use ExtendsMediaAbilities;

	// ...
}
```

Documentation
-------------

[](#documentation)

Find the complete documentation of the base package here: .

Translations
------------

[](#translations)

All captions are translatable.

See how to translate them on the Laravel official documentation: .

Here is the list of the sentences available for translation:

- `Min. width: :width px.`
- `Min. height: :height px.`
- `{1}Accepted type: :types.|[2,*]Accepted types: :types.`
- `Max. file size: :size Mb.`

Extension features
------------------

[](#extension-features)

### Media validation rules

[](#media-validation-rules)

Declaring your media validation rules like this:

```
// In your user storing form request for example
public function rules()
{
    return [
        'avatar' => (new User)->getMediaValidationRules('avatar'),
        // your other validation rules
    ];
}
```

Will generate:

```
    // Example
    ['mimetypes:image/jpeg,image/png', 'mimes:jpg,jpeg,jpe,png', 'dimensions:min_width=60,min_height=20', 'max:5000'];
```

#### Available public methods:

[](#available-public-methods)

- `->getMediaValidationRules(string $collectionName): array`: returns all the validation rules for the given collection.
- `->getMediaMimesValidationRules(string $collectionName): string`: returns only the mimes validation rules for the given collection.
- `->getMediaMimeTypesValidationRules(string $collectionName): string`: returns only the mime types validation rules for the given collection.
- `->getMediaDimensionValidationRules(string $collectionName): string`: returns only the dimension validation rules for the given collection.
- `->getMediaSizeValidationRule(): string`: returns only the max file size validation rule set from the base package `media-library.max_file_size` configuration value.

### Media caption

[](#media-caption)

Adding a constraint caption under a file input:

```

Choose a profile picture:

{{ $user->getMediaCaption('avatar') }}
```

Will generate:

```

    Min. width: 150 px. Min. height: 70 px. Accepted types: jpg, jpeg, jpe, png. Max file size: 5Mb.
```

#### Available public methods:

[](#available-public-methods-1)

- `getMediaCaption(string $collectionName): string`: returns a complete caption for the given collection.
- `getMediaDimensionsCaption(string $collectionName): string`: returns only the dimensions caption for the given collection.
- `getMediaMimeTypesCaption(string $collectionName): string`: returns only the mime types caption for the given collection.
- `getMediaSizeCaption(): string`: returns only the config max file size caption only.

### Exceptions

[](#exceptions)

In order to avoid careless mistakes when using public methods that are requiring a `string $collectionName` argument provided by this extension, an `Okipa\MediaLibraryExt\Exceptions\CollectionNotFound` exception will be thrown when the given collection name is not found in the targeted model.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Arthur LORENT](https://github.com/okipa)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity95

Battle-tested with a long release history

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Recently: every ~90 days

Total

269

Last Release

1252d ago

Major Versions

6.9.2 → 7.5.22018-11-19

7.19.2 → 8.0.02020-04-01

7.19.3 → 8.0.12020-09-03

8.1.0 → 9.0.02020-10-30

9.2.0 → 10.0.02022-01-24

PHP version history (11 changes)0.1.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.5.0

3.12.0PHP ^5.5|^7.0

4.0.0PHP ^7.0

7.0.0PHP ^7.1

7.6.0PHP ^7.2

8.0.0PHP ^7.4

9.1.0PHP ^7.4||^8.0

10.0.0PHP ^8.0|^8.1

10.1.0PHP ^8.1|^8.2

10.2.0PHP 8.1.\*|8.2.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc5b2b60afe2f6f28bd3ef5105fc1883386967efcc744b1b6829b8eb289f5a91?d=identicon)[Okipa](/maintainers/Okipa)

---

Tags

cmsconversiondownloadsextensionimageslaravellaravel-medialibrarymediaokipaspatiespatielaravelconversionimagesmediacmsdownloadslaravel-medialibraryextensionokipalaravel-medialibrary-extension

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/okipa-laravel-medialibrary-ext/health.svg)

```
[![Health](https://phpackages.com/badges/okipa-laravel-medialibrary-ext/health.svg)](https://phpackages.com/packages/okipa-laravel-medialibrary-ext)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k41.3M600](/packages/spatie-laravel-medialibrary)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
