PHPackages                             escapework/laramedias - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. escapework/laramedias

ActiveLibrary[File &amp; Storage](/categories/file-storage)

escapework/laramedias
=====================

A Laravel package that integrates Glide for easily manage medias on your project.

0.9.0(4y ago)191.9kMIT

Since Feb 24Compare

[ Source](https://github.com/EscapeWork/laramedias)[ Packagist](https://packagist.org/packages/escapework/laramedias)[ RSS](/packages/escapework-laramedias/feed)WikiDiscussions Synced today

READMEChangelogDependencies (7)Versions (30)Used By (0)

 [![Laramedias](https://camo.githubusercontent.com/6663bf1e97ca2388b5bc12a00fc759c029a4568db2775af5c6f2970da1ef61fa/687474703a2f2f692e696d6775722e636f6d2f313979483356572e706e67)](https://camo.githubusercontent.com/6663bf1e97ca2388b5bc12a00fc759c029a4568db2775af5c6f2970da1ef61fa/687474703a2f2f692e696d6775722e636f6d2f313979483356572e706e67)

[![Latest Stable Version](https://camo.githubusercontent.com/089b1eee332a729139bc071a71d4b777175bbb90b084ea27984a36f96e7aa141/68747470733a2f2f706f7365722e707567782e6f72672f657363617065776f726b2f6c6172616d65646961732f762f737461626c652e706e67)](https://packagist.org/packages/escapework/laramedias)[![Downloads](https://camo.githubusercontent.com/c2234609b7d33093b8be73d654326478e7db43d54a7221eb57fa07b887b9495d/68747470733a2f2f706f7365722e707567782e6f72672f657363617065776f726b2f6c6172616d65646961732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/escapework/laramedias)[![Travis - Build Status](https://camo.githubusercontent.com/459ed6900a4606294ce721b2c5be93fc4c4c135391268ca5c5c5c94d7ef51a0f/68747470733a2f2f7472617669732d63692e6f72672f457363617065576f726b2f6c6172616d65646961732e706e67)](https://travis-ci.org/EscapeWork/laramedias)[![License MIT](https://camo.githubusercontent.com/39ff59380d93c3968ba217c64fbcd3383bc1b685db8b6dd208aef72733f49d57/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f457363617065576f726b2f6c6172616d65646961732e7376673f7374796c653d666c6174)](https://github.com/EscapeWork/laramedias)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/67dc30adada6f99fd1fd47cc626e693a2d549789e089c4164cf01b68dbcbf6b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f457363617065576f726b2f6c6172616d65646961732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://github.com/EscapeWork/laramedias)

A Laravel package that integrates \[Glide\]() and easy media management on your Laravel project.

```

```

Version Compatibility
---------------------

[](#version-compatibility)

LaravelLaramedias9.0.x0.9.x5.5.x5.6.x5.4.x0.6.x5.4.x0.5.x5.3.x0.4.x5.2.x0.3.x5.1.x0.2.xInstallation
------------

[](#installation)

Via Composer:

```
$ composer require escapework/laramedias:"0.7.*"

```

Configuration
-------------

[](#configuration)

And execute the following code:

```
$ php artisan vendor:publish --provider="EscapeWork\LaraMedias\Providers\MediasServiceProvider"
$ php artisan migrate

```

Configurations explained:

```
'disk' => null, // if you dont want to use filesystems.default disk config, change it here...
                // ...for saving on another disk

'max_size' => [
    'width'  => 2000, // when creating medias, the images will be resized to this max_size...
    'height' => 2000, // ...for reducing disk usage
],

'url'  => 'medias',  // if you want to change the laravel glide medias URL
'dir'  => 'medias',  // if you want to change the default directory where the medias are saved
'path' => 'general', // if you want to change the directory where the multipleMedias are saved (you will undestand this later)
```

Usage
-----

[](#usage)

This package allows you to easily use medias with your laravel models. There are two basic ways to use:

### One model has multiple medias

[](#one-model-has-multiple-medias)

Let's say you have a `Product` model that need to have multiple medias. You have to do this:

- Import the following trait in your model;

```
use EscapeWork\LaraMedias\Traits\Medias;

class Product extends Model
{

    use Medias;
}
```

Now, you can do this:

##### Upload and create multiple medias:

[](#upload-and-create-multiple-medias)

```
$product->uploadMedias($request->file('medias'));
```

##### Interate through your medias

[](#interate-through-your-medias)

The `$product->medias` will be a default Laravel collection of `EscapeWork\LaraMedias\Models\Media` models which you can use any of the collection methods available.

```
@foreach ($product->medias as $media)

@endforeach
```

Each `$media` object will be a `LaraMedias\Models\Media` eloquent model, which will have a presenter for easily displaying images (see the above example).

The parameters in the example are the [Glide](http://glide.thephpleague.com/) width (`w`), height (`h`) and `fit`. You can see a simple example here ().

If your model was deleted, all the medias will be deleted too.

##### Deleting medias

[](#deleting-medias)

For delete your medias, just call the method `removeMedias`.

```
$product->removeMedias([1, 2]); // just pass the IDs
```

For removing all medias, just call the `removeMedias` method without any parameters.

```
$product->removeMedias();
```

#### Events

[](#events)

These events are dispatched when in the above use case:

ActionEventEscapeWork\\LaraMedias\\Models\\Media::createdEscapeWork\\LaraMedias\\Events\\MediaAddedEscapeWork\\LaraMedias\\Models\\Media::updatedEscapeWork\\LaraMedias\\Events\\MediaUpdatedEscapeWork\\LaraMedias\\Models\\Media::deletedEscapeWork\\LaraMedias\\Events\\MediaDeleted### One model has one media field

[](#one-model-has-one-media-field)

Let's say you have a `Banner` model and want to upload a single image for him. With `Laramedias` you can do this:

First, configure the `config/medias.php` file:

```
    'models' => [
        'banners' => [
            'model'  => 'App\Models\Banner',
            'fields' => ['banner'] // here you have to put the fields in your model which use medias
        ],
    ],
```

Second, use the `EscapeWork\LaraMedias\Traits\Medias` trait in your `Banner` model.

```
use EscapeWork\LaraMedias\Traits\Medias;

class Banner extends Model
{

    use Medias;
}
```

Then, you can just use the `uploadSingleMedia` method.

```
$banner = Banner::find(1);
$banner->uploadSingleMedia($request->file('banner'), 'banner'); // the second parameter is the field name to be updated
$banner->save();
```

After that, you can just use the `media` helper method to show your banner.

```

```

I would also recomend in this case to make use of [Presenters](https://github.com/EscapeWork/LaravelSteroids#presenters). You can use your custom setup or make use of [this package](https://github.com/EscapeWork/LaravelSteroids#presenters) that makes it very easy.

Then, you can setup like this:

```
use EscapeWork\LaravelSteroids\Presenter;

class BannerPresenter extends Presenter
{
    public function banner($w = 100, $h = 50, $fit = 'fit')
    {
        return media_path($this->model, 'banner', $w, $h, $fit);
    }
}
```

And you like this:

```

```

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

[](#contributing)

Feel free to open any pull request/issue with your idea/bug/suggestion.

License
-------

[](#license)

See the [License](https://github.com/EscapeWork/laravel-asset-versioning/blob/master/LICENSE) file.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% of commits — single point of failure

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 ~83 days

Recently: every ~441 days

Total

28

Last Release

1531d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57e405b52d482c9de35b17f299d2745e8e68d9d9951aec64854f2d7fa53110bf?d=identicon)[luisdalmolin](/maintainers/luisdalmolin)

---

Top Contributors

[![luisdalmolin](https://avatars.githubusercontent.com/u/403446?v=4)](https://github.com/luisdalmolin "luisdalmolin (125 commits)")[![eduardoescape](https://avatars.githubusercontent.com/u/64859891?v=4)](https://github.com/eduardoescape "eduardoescape (3 commits)")[![edufiorenza](https://avatars.githubusercontent.com/u/7750555?v=4)](https://github.com/edufiorenza "edufiorenza (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/escapework-laramedias/health.svg)

```
[![Health](https://phpackages.com/badges/escapework-laramedias/health.svg)](https://phpackages.com/packages/escapework-laramedias)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.5M925](/packages/statamic-cms)[awcodes/filament-curator

A media picker plugin for FilamentPHP.

436333.6k24](/packages/awcodes-filament-curator)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4923.6k5](/packages/ralphjsmit-laravel-glide)[justbetter/statamic-image-optimize

Image optimization after upload

1318.4k](/packages/justbetter-statamic-image-optimize)

PHPackages © 2026

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