PHPackages                             jeffreyvanrossum/laravel-simple-media - 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. jeffreyvanrossum/laravel-simple-media

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

jeffreyvanrossum/laravel-simple-media
=====================================

A simple media package for Laravel.

312PHP

Since Jun 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jeffreyvr/laravel-simple-media)[ Packagist](https://packagist.org/packages/jeffreyvanrossum/laravel-simple-media)[ RSS](/packages/jeffreyvanrossum-laravel-simple-media/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

SimpleMedia For Laravel
=======================

[](#simplemedia-for-laravel)

SimpleMedia for Laravel is package to handle media attached or unattached to Eloquent models.

This package is very much a work in progess.

For a more fleshed out package, you might consider trying [Laravel Medialibrary](https://github.com/spatie/laravel-medialibrary) from [Spatie](https://github.com/spatie).

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

[](#installation)

```
composer require jeffreyvanrossum/laravel-simple-media
```

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

[](#configuration)

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Jeffreyvr\SimpleMedia\SimpleMediaServiceProvider" --tag="migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Jeffreyvr\SimpleMedia\SimpleMediaServiceProvider" --tag="config"
```

### Automatically generate additional image sizes

[](#automatically-generate-additional-image-sizes)

This can be handy if you for example would like to generate thumbnails of your images. You could define a thumbnail image size like this in the config:

```
'image_sizes' => [
    'thumbnail' => [
        'width' => 100,
        'height' => 100,
        'crop' => true // determine if the image needs to be cropped
    ],
    // etc.
]
```

### Image drivers

[](#image-drivers)

The default image driver is `gd`. You could also specify `imagick` in the config file.

### Storage

[](#storage)

You can specifiy which [File Storage](https://laravel.com/docs/7.x/filesystem) disk should be used for your uploads in the configuration file. By default, it uses `public`.

Usage
-----

[](#usage)

### Adding unattached files and images

[](#adding-unattached-files-and-images)

To upload you can use the `uploadImage` and `uploadFile` methods on the `Media` model.

```
Media::uploadImage($file); // for images

Media::uploadFile($file); // for files other then images
```

Calling these methods will automatically insert a record into the database. You specify/overwrite attributes by providing a second parameter to those methods.

```
Media::uploadImage($file, ['name' => 'A custom name', 'group' => 'profile-images']);
```

You can upload to a different disk then the one that is specified in the configuration file like this:

```
Media::uploadImage($file, ['disk' => 'local']);
```

You can handle uploads from the `Request` by using these methods:

```
Media::uploadFileFromRequest($key);
Media::uploadImageFromRequest($key);
```

To retrieve media, you can do the following:

```
Media::all();
Media::where('group', $group)->get();  // etc.
```

### Attaching to Eloquent models

[](#attaching-to-eloquent-models)

To attach media to Eloquent models, you must first add the `HasMedia` trait to the model.

You specify/overwrite attributes by providing a second parameter (`array`) to those methods.

```
$post->attachImage($file); // for images

$post->attachFile($file); // for files other then images
```

Or if you want to use a file from the request, you can do this:

```
$post->attachImageFromRequest($key);
$post->attachFileFromRequest($key);
```

To retrieve the media, you can do the following:

```
$post->media();
```

Blade:

```
@foreach ($post->media as $file)
    {{$file->getOriginalUrl()}}
@endforeach
```

To retrieve media by group you can do this:

```
$post->mediaByGroup('profile-images')->get();
```

### Deleting media

[](#deleting-media)

If you call the `delete` method on an instance of `Media`, it will delete the record and the associatated files on the disk.

```
$media->delete();
```

Notes
-----

[](#notes)

- If you don't specify a group, an image upload will get `images` as group by default. Other files will have `files` as default group.
- If a file name is used that is not unique within the destination folder, it will append a number to the name that will increment untill it is unique.
- The package does not restrict on file types. There is no file type validation, you could implement that yourself if needed.

Todo
----

[](#todo)

- Implement some basic quality reduction and/or compression.
- On delete, also delete the files from the disk.
- Better support upload from request.
- Add more tests.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/66ca71465f93459010e10f39821b541f1c00c61233c48bcda0cea8a8d6fb6988?d=identicon)[jeffreyvr](/maintainers/jeffreyvr)

---

Top Contributors

[![jeffreyvr](https://avatars.githubusercontent.com/u/9550079?v=4)](https://github.com/jeffreyvr "jeffreyvr (3 commits)")

### Embed Badge

![Health badge](/badges/jeffreyvanrossum-laravel-simple-media/health.svg)

```
[![Health](https://phpackages.com/badges/jeffreyvanrossum-laravel-simple-media/health.svg)](https://phpackages.com/packages/jeffreyvanrossum-laravel-simple-media)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)

PHPackages © 2026

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