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

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

shortcodes/media
================

Package to organise media files and it's customization

1.2(4y ago)62.5k1mitPHPPHP &gt;=7.0.0

Since Jul 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/shortcodes/media)[ Packagist](https://packagist.org/packages/shortcodes/media)[ RSS](/packages/shortcodes-media/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (1)Versions (32)Used By (0)

Deprecated
==========

[](#deprecated)

This package is deprecated. New and improved version of it here

Mediable
========

[](#mediable)

Package to organise media files and it's customization

Install
=======

[](#install)

```
composer require shortcodes/media

```

Usage
=====

[](#usage)

Model must use trait `Shortcodes/Media/Mediable` and implement `HasMedia` interface

### Register collections

[](#register-collections)

To register collections add method `registerMediaCollections` and add collections you need

```
public function registerMediaCollections()
{
    $this->addMediaCollection('avatar')->singleFile();
    $this->addMediaCollection('my-other-collection');
}

```

You can define if collection is singular (add `singleFile()` method) or multiple (by default)

### Uploading media files

[](#uploading-media-files)

To be able to upload media files you have to set media routes. You can do that by placing `Route::mediaRoutes(); ` in your routes file.

Then you will be able to use it under `POST /media` in basic namespace while providing `file` field

In response you will get:

```
"data": {
  "id": 1,
  "name": "example",
  "size": 272605,
  "url": "http://localhost/storage/60/example.jpg"
}

```

> If your disk is not set to public the URL you receive will be proper for chosen disk.

After uploading media it is placed in `MediaLibrary` and can be attach to model

### Attaching single file to model

[](#attaching-single-file-to-model)

To attach file to model you need simply to make request (`POST` or `PATCH`) to create or modify model with parameters previously described in `registerMediaCollections` method like in example

```
Model::create([...$someArticleAttributes,
    'avatar': 1
]);

```

In `avatar` single collection you need to provide media id received while uploading media.

> While updating model object that already have an avatar and collection is set to `singleFile()` avatar will be replaced

### Attaching multiple files to model

[](#attaching-multiple-files-to-model)

To attach multiple media files to model you need simply to make request (`POST` or `PATCH`) to create or modify model with parameters previously described in `registerMediaCollections` method like in example

```
Model::create([...$someArticleAttributes,
    'my-other-collection': [1,2,3,4]
]);

```

In `my-other-collection` property collection you need to provide array of media ids received while uploading media.

> REMEMBER! While updating model object collection not set to single all skipped media id in array will be deleted.

In this case images are automatically reordered by provided `ids`.

### Attaching multiple files to model without removing actual

[](#attaching-multiple-files-to-model-without-removing-actual)

In case you need to add media file without removing all missing in array you can use `add` key in collection data request

```
Model::create([...$someArticleAttributes,
    'my-other-collection': [
        'add' => [1]
    ]
]);

```

### Deleting selected files from model

[](#deleting-selected-files-from-model)

In case you need to remove selected media from object you can use `delete` key in collection data request

```
Model::create([...$someArticleAttributes,
    'my-other-collection': [
        'delete' => [3, 4]
    ]
]);

```

### Attaching file while uploading

[](#attaching-file-while-uploading)

You may also attach file directly to demanded models providing proper fields in request `model_type`,`model_id`,`model_collection`.

The `model_collection` field is optional. Remember that `model_type` must use trait `Mediable`

### Attach manipulations to uploaded image

[](#attach-manipulations-to-uploaded-image)

You may also add some manipulations to uploaded media.

For now only available manipulation ther is is cropping.

You can perform it by performing PATCH request

```
PATCH /media/{mediaId}

{
   "manipulations": [
       {
           "type":"crop",
           "x":0,
           "y":0,
           "width":10,
           "height": 500
       }
   ]
}

```

where `x` and `y` are coordinates to starting point and `width` and `height` are dimentions of cropped rectangle.

### Additional features

[](#additional-features)

More about library can be found at official documentation page

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~26 days

Recently: every ~91 days

Total

29

Last Release

1731d ago

Major Versions

0.0.9 → 1.0.02019-10-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30219536?v=4)[Roman Szymański](/maintainers/shortcodes)[@shortcodes](https://github.com/shortcodes)

---

Top Contributors

[![shortcodes](https://avatars.githubusercontent.com/u/30219536?v=4)](https://github.com/shortcodes "shortcodes (3 commits)")[![mg10110](https://avatars.githubusercontent.com/u/32193892?v=4)](https://github.com/mg10110 "mg10110 (2 commits)")

---

Tags

deprecated

### Embed Badge

![Health badge](/badges/shortcodes-media/health.svg)

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

###  Alternatives

[dmitrybubyakin/nova-medialibrary-field

Laravel Nova field for managing the Spatie media library.

268612.7k2](/packages/dmitrybubyakin-nova-medialibrary-field)[ahmed-aliraqi/laravel-media-uploader

This package used to upload files using laravel-media-library

34024.3k3](/packages/ahmed-aliraqi-laravel-media-uploader)[backpack/medialibrary-uploaders

Helper functions to save files with spatie media library

1373.3k](/packages/backpack-medialibrary-uploaders)[josefbehr/filament-spatie-media-library-croppie

A filament form field for image upload using spatie media library and croppie.js

126.6k](/packages/josefbehr-filament-spatie-media-library-croppie)[gaspertrix/laravel-backpack-dropzone-field

Add Dropzone support for Laravel Backpack

172.2k](/packages/gaspertrix-laravel-backpack-dropzone-field)

PHPackages © 2026

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