PHPackages                             gterrusa/frontendmedialibrary - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gterrusa/frontendmedialibrary

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gterrusa/frontendmedialibrary
=============================

:package\_description

1.1.4(4y ago)12.8k↓47.1%1MITPHPCI failing

Since May 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/gTerrusa/frontend-medialibrary)[ Packagist](https://packagist.org/packages/gterrusa/frontendmedialibrary)[ Docs](https://github.com/gterrusa/frontendmedialibrary)[ RSS](/packages/gterrusa-frontendmedialibrary/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (7)Used By (1)

FrontendMedialibrary
====================

[](#frontendmedialibrary)

[![Latest Version on Packagist](https://camo.githubusercontent.com/93d611db7ffcc2793cd487a2194f08b2637016913e56ee92987279fd2d1db16a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67746572727573612f66726f6e74656e646d656469616c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gterrusa/frontendmedialibrary)[![Total Downloads](https://camo.githubusercontent.com/16bbf55b76b80c0902508043e7a14ab11e7a6b767c5d64571c8301b937e14b9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67746572727573612f66726f6e74656e646d656469616c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gterrusa/frontendmedialibrary)[![Build Status](https://camo.githubusercontent.com/a7dd2a2d3d293adaf819a7417c1f160ade1fc638c3ef83b9b13b6a467b4f9a7e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f67746572727573612f66726f6e74656e646d656469616c6962726172792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gterrusa/frontendmedialibrary)[![StyleCI](https://camo.githubusercontent.com/cb13a877afd1dbe223c631789c3f922d3ace958fdb334a9cce9b26afefbc2ebd/68747470733a2f2f7374796c6563692e696f2f7265706f732f31323334353637382f736869656c64)](https://styleci.io/repos/12345678)

FrontendMedialibrary is a trait that makes the media, on your Laravel models that use Spatie Medialibrary, more easily accessible in frontend frameworks. Take a look at [contributing.md](contributing.md) to see a to do list.

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

[](#installation)

Via Composer

```
$ composer require gterrusa/frontendmedialibrary
```

Usage
-----

[](#usage)

Set up your Model

```
/**
 * Model must be using Spatie Medialibrary
 */

class User extends Model implements HasMedia
{
    use InteractsWithMedia, HasFrontendMedia;

    // If you would like the frontendMedia attribute included with your model automatically
    protected $appends = ['frontendMedia'];

    /**
     * Spatie medialibrary media collections
     * any media collections can be set up here
     * this is just an example.
     */
    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('avatar')->singleFile();

        $this->addMediaCollection('user_gallery');
    }

    /**
     * Spatie medialibrary media conversions
     * any media conversions can be set up here
     * this is just an example
     */
    public function registerMediaConversions(Media $media = null): void
    {
        $this->addMediaConversion('optimized')
            ->fit(Manipulations::FIT_MAX, 1500, 1500);

        $this->addMediaConversion('thumb')
            ->fit(Manipulations::FIT_MAX, 250, 250);
    }
}

```

Example Result:

\*\* HasFrontendMedia will pick up all of your registered collections, conversions, and custom properties automatically. They do not have to be these exact ones. This is just an example of the structure of the output.

```
>>> $user->frontendMedia;
=> Illuminate\Support\Collection {#4382
     all: [
       "avatar" => Illuminate\Support\Collection {#4439
         all: [
           [
             "src" => "http://frontend-medialibrary.local/storage/1/41301408.jpeg",
             "conversions" => Illuminate\Support\Collection {#4425
               all: [
                 "thumb" => "http://frontend-medialibrary.local/storage/1/conversions/41301408-thumb.jpg",
                 "optimized" => "http://frontend-medialibrary.local/storage/1/conversions/41301408-optimized.jpg",
               ],
             },
             "custom_properties" => Illuminate\Support\Collection {#4384
               all: [
                 "alt" => "my alt tag",
               ],
             },
           ],
         ],
       },
       "user_gallery" => Illuminate\Support\Collection {#4469
         all: [
           [
             "src" => "http://frontend-medialibrary.local/storage/2/49268400_10155665639226152_4845558111659884544_n.jpg",
             "conversions" => Illuminate\Support\Collection {#4443
               all: [
                 "thumb" => "http://frontend-medialibrary.local/storage/2/conversions/49268400_10155665639226152_4845558111659884544_n-thumb.jpg",
                 "optimized" => "http://frontend-medialibrary.local/storage/2/conversions/49268400_10155665639226152_4845558111659884544_n-optimized.jpg",
               ],
             },
             "custom_properties" => Illuminate\Support\Collection {#4456
               all: [],
             },
           ],
           [
             "src" => "http://frontend-medialibrary.local/storage/3/68544499_10156079858431152_5954628979427115008_n.jpg",
             "conversions" => Illuminate\Support\Collection {#4444
               all: [
                 "thumb" => "http://frontend-medialibrary.local/storage/3/conversions/68544499_10156079858431152_5954628979427115008_n-thumb.jpg",
                 "optimized" => "http://frontend-medialibrary.local/storage/3/conversions/68544499_10156079858431152_5954628979427115008_n-optimized.jpg",
               ],
             },
             "custom_properties" => Illuminate\Support\Collection {#4470
               all: [],
             },
           ],
         ],
       },
     ],
   }

```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [author name](https://github.com/gterrusa)
- [All Contributors](../../contributors)

License
-------

[](#license)

license. Please see the [license file](license.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~57 days

Recently: every ~71 days

Total

6

Last Release

1602d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46fd6aa09c00a26cc86e7dac1f5cc8ecb744a4a9fc25c13e0d701fccef998f9a?d=identicon)[gTerrusa](/maintainers/gTerrusa)

---

Top Contributors

[![gTerrusa](https://avatars.githubusercontent.com/u/41301408?v=4)](https://github.com/gTerrusa "gTerrusa (10 commits)")

---

Tags

laravelFrontendMedialibrary

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gterrusa-frontendmedialibrary/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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