PHPackages                             tahirrasheed208/laravel-medialibrary - 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. tahirrasheed208/laravel-medialibrary

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

tahirrasheed208/laravel-medialibrary
====================================

Media Library for Laravel

4.1.2(11mo ago)21.0kMITPHPPHP ^8.2

Since Oct 4Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/tahirrasheed208/laravel-medialibrary)[ Packagist](https://packagist.org/packages/tahirrasheed208/laravel-medialibrary)[ RSS](/packages/tahirrasheed208-laravel-medialibrary/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (38)Used By (0)

Media Library for Laravel
=========================

[](#media-library-for-laravel)

This package can associate images with Eloquent models.

[![Latest Version on Packagist](https://camo.githubusercontent.com/0a8459ac57992730fc653ef45c496eb78dcb2baeacfd309248863f665e1030cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7461686972726173686565643230382f6c61726176656c2d6d656469616c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tahirrasheed208/laravel-medialibrary)[![Total Downloads](https://camo.githubusercontent.com/82df6e3cd0c63ecca23c3cf1d30579019f5b61acee7e4aa658152d7627b21904/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7461686972726173686565643230382f6c61726176656c2d6d656469616c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tahirrasheed208/laravel-medialibrary)

Getting Started
---------------

[](#getting-started)

### 1. Install

[](#1-install)

Run the following command:

```
composer require tahirrasheed208/laravel-medialibrary
```

### 2. Publish

[](#2-publish)

Publish config file.

```
php artisan vendor:publish --provider="TahirRasheed\MediaLibrary\MediaLibraryServiceProvider" --tag=medialibrary-config
```

### 3. Preparing the database

[](#3-preparing-the-database)

You need to publish the migration to create the media table:

```
php artisan vendor:publish --provider="TahirRasheed\MediaLibrary\MediaLibraryServiceProvider" --tag=medialibrary-migration
```

After that, you need to run migrations.

```
php artisan migrate
```

Usage
-----

[](#usage)

Your Eloquent models should use the `TahirRasheed\MediaLibrary\Traits\HasMedia` trait.

Use blade component to add file uploader in your form.

```

```

For display old image in edit page.

```

```

Upload
------

[](#upload)

```
$model = Model::find(1);
$model->handleMediaFromRequest()->toMediaCollection();
```

If your file input name is not `image` then define second param.

```
$model->handleMediaFromRequest('banner')->toMediaCollection();
```

Upload to specific collection.

```
$model->handleMediaFromRequest()->toMediaCollection('images');
```

You can define default collection at eloquent level. Add below function in your model.

```
public function defaultCollection(): string
{
    return 'post_images';
}
```

Upload to specific disk.

```
$model->handleMediaFromRequest()->useDisk('s3')->toMediaCollection();
```

### Register Media Conversions

[](#register-media-conversions)

```
public function registerMediaConversions()
{
    $this->addMediaConversion('post_main')
        ->width(420)
        ->height(350);
}
```

You can register as many media conversions as you want

```
public function registerMediaConversions()
{
    $this->addMediaConversion('post_main')
        ->width(420)
        ->height(350);

    $this->addMediaConversion('post_detail')
        ->width(700)
        ->height(550);
}
```

Default force crop is disabled, but you can enable it

```
$this->addMediaConversion('post_main')
    ->width(420)
    ->height(350)
    ->crop();
```

### Disable Conversions

[](#disable-conversions)

If you want to disable registered conversions on some files

```
$model->handleMediaFromRequest()->withoutConversions()->toMediaCollection();
```

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

[](#configuration)

Define your layout stack in config file.

```
'stack' => 'footer',
```

Or you can use our blade directive.

```
@mediaLibraryScript
```

Gallery with Dropzone
---------------------

[](#gallery-with-dropzone)

```

```

Attach gallery to model using blelow code.

```
$model->attachGalleryToModelFromRequest('gallery')->toMediaCollection();
```

You can also define collection for gallery.

```

```

You can define model to dropzone component as well. When you define model to component all images are automatically attached to model.

```

```

You can also change the default dropzone message.

```

```

Add Media from Url
------------------

[](#add-media-from-url)

```
$model->addMediaFromUrl($url, 'image')->toMediaCollection();
```

Implements with Laravel Settings
--------------------------------

[](#implements-with-laravel-settings)

Install settings package

```
composer require tahirrasheed208/laravel-settings
```

Blade component to display old file

```

```

To upload file

```
setting()->upload($request->toArray(), 'file_name');
```

By default we expect file name is your option name, but you can define your option name as well

```
setting()->upload($request->toArray(), 'file_name', 'option_name');
```

### Get Uploaded File Url

[](#get-uploaded-file-url)

```
setting()->getFile('name');
```

Changelog
---------

[](#changelog)

Please see [Releases](../../releases) for more information what has changed recently.

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

[](#contributing)

Pull requests are more than welcome. You must follow the PSR coding standards.

Security
--------

[](#security)

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

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance52

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity71

Established project with proven stability

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

Recently: every ~63 days

Total

37

Last Release

333d ago

Major Versions

1.5.0 → 2.0.02022-10-20

2.4.6 → 3.0.02024-06-13

3.1.4 → 4.0.02024-08-26

v2.4.7 → 4.1.22025-06-13

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

3.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![tahirrasheed208](https://avatars.githubusercontent.com/u/48022959?v=4)](https://github.com/tahirrasheed208 "tahirrasheed208 (99 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[livewire-filemanager/filemanager

A simple, friendly and practical Livewire filemanager for your applications

3587.6k1](/packages/livewire-filemanager-filemanager)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4719.6k5](/packages/ralphjsmit-laravel-glide)

PHPackages © 2026

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