PHPackages                             kayacekovic/advanced-nova-media-library - 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. kayacekovic/advanced-nova-media-library

ActiveLibrary

kayacekovic/advanced-nova-media-library
=======================================

Laravel Nova tools for managing the Spatie media library.

3.6.6(4y ago)010MITVuePHP &gt;=7.4

Since Oct 1Pushed 4y agoCompare

[ Source](https://github.com/kayacekovic/advanced-nova-media-library)[ Packagist](https://packagist.org/packages/kayacekovic/advanced-nova-media-library)[ RSS](/packages/kayacekovic-advanced-nova-media-library/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (43)Used By (0)

Laravel Advanced Nova Media Library
===================================

[](#laravel-advanced-nova-media-library)

Manage images of [spatie's media library package](https://github.com/spatie/laravel-medialibrary). Upload multiple images and order them by drag and drop.

##### Table of Contents

[](#table-of-contents)

- [Examples](#examples)
- [Install](#install)
- [Model media configuration](#model-media-configuration)
- [Generic file management](#generic-file-management)
- [Single image upload](#single-image-upload)
- [Multiple image upload](#multiple-image-upload)
- [Selecting existing media](#selecting-existing-media)
- [Names of uploaded images](#names-of-uploaded-images)
- [Image cropping](#image-cropping)
- [Custom properties](#custom-properties)
- [Custom headers](#custom-headers)
- [Media Field (Video)](#media-field-video)

Examples
--------

[](#examples)

[![Cropping](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/cropping.gif)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/cropping.gif)[![Single image upload](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/single-image.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/single-image.png)[![Multiple image upload](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/multiple-images.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/multiple-images.png)[![Custom properties](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/custom-properties.gif)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/custom-properties.gif)[![Generic file management](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/file-management.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/file-management.png)

Install
-------

[](#install)

```
composer require ebess/advanced-nova-media-library
```

```
php artisan vendor:publish --tag=nova-media-library
```

Model media configuration
-------------------------

[](#model-media-configuration)

Let's assume you configured your model to use the media library like following:

```
use Spatie\MediaLibrary\MediaCollections\Models\Media;

public function registerMediaConversions(Media $media = null)
{
    $this->addMediaConversion('thumb')
        ->width(130)
        ->height(130);
}

public function registerMediaCollections()
{
    $this->addMediaCollection('main')->singleFile();
    $this->addMediaCollection('my_multi_collection');
}
```

Generic file management
-----------------------

[](#generic-file-management)

[![Generic file management](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/file-management.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/file-management.png)

In order to be able to upload and handle generic files just go ahead and use the `Files` field.

```
use Ebess\AdvancedNovaMediaLibrary\Fields\Files;

Files::make('Single file', 'one_file'),
Files::make('Multiple files', 'multiple_files'),
```

Single image upload
-------------------

[](#single-image-upload)

[![Single image upload](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/single-image.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/single-image.png)

```
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;

public function fields(Request $request)
{
    return [
        Images::make('Main image', 'main') // second parameter is the media collection name
            ->conversionOnIndexView('thumb') // conversion used to display the image
            ->rules('required'), // validation rules
    ];
}
```

Multiple image upload
---------------------

[](#multiple-image-upload)

If you enable the multiple upload ability, you can **order the images via drag &amp; drop**.

[![Multiple image upload](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/multiple-images.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/multiple-images.png)

```
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;

public function fields(Request $request)
{
    return [
        Images::make('Images', 'my_multi_collection') // second parameter is the media collection name
            ->conversionOnPreview('medium-size') // conversion used to display the "original" image
            ->conversionOnDetailView('thumb') // conversion used on the model's view
            ->conversionOnIndexView('thumb') // conversion used to display the image on the model's index page
            ->conversionOnForm('thumb') // conversion used to display the image on the model's form
            ->fullSize() // full size column
            ->rules('required', 'size:3') // validation rules for the collection of images
            // validation rules for the collection of images
            ->singleImageRules('dimensions:min_width=100'),
    ];
}
```

Selecting existing media
------------------------

[](#selecting-existing-media)

[![Selecting existing media](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/existing-media.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/existing-media.png)[![Selecting existing media 2](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/existing-media-2.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/existing-media-2.png)

If you upload the same media files to multiple models and you do not want to select it from the file system all over again, use this feature. Selecting an already existing media will **copy it**.

**Attention**: This feature will expose an endpoint to every user of your application to search existing media. If your media upload / custom properties on the media models are confidential, **do not enable this feature!**

- Publish the config files if you did not yet

```
artisan vendor:publish --tag=nova-media-library
```

- Enable this feature in config file *config/nova-media-library*

```
return [
    'enable-existing-media' => true,
];
```

- Enable the selection of existing media field

```
Images::make('Image')->enableExistingMedia(),
```

**Note**: This feature does not support temporary URLs.

Names of uploaded images
------------------------

[](#names-of-uploaded-images)

The default filename of the new uploaded file is the original filename. You can change this with the help of the function `setFileName`, which takes a callback function as the only param. This callback function has three params: `$originalFilename` (the original filename like `Fotolia 4711.jpg`), `$extension` (file extension like `jpg`), `$model` (the current model). Here are just 2 examples of what you can do:

```
// Set the filename to the MD5 Hash of original filename
Images::make('Image 1', 'img1')
    ->setFileName(function($originalFilename, $extension, $model){
        return md5($originalFilename) . '.' . $extension;
    });

// Set the filename to the model name
Images::make('Image 2', 'img2')
    ->setFileName(function($originalFilename, $extension, $model){
        return str_slug($model->name) . '.' . $extension;
    });
```

By default, the "name" field on the Media object is set to the original filename without the extension. To change this, you can use the `setName` function. Like `setFileName` above, it takes a callback function as the only param. This callback function has two params: `$originalFilename` and `$model`.

```
Images::make('Image 1', 'img1')
    ->setName(function($originalFilename, $model){
        return md5($originalFilename);
    });
```

Responsive images
-----------------

[](#responsive-images)

If you want to use responsive image functionality from the [Spatie MediaLibrary](https://docs.spatie.be/laravel-medialibrary/v7/responsive-images/getting-started-with-responsive-images), you can use the `withResponsiveImages()` function on the model.

```
Images::make('Image 1', 'img1')
    ->withResponsiveImages();
```

Image cropping
--------------

[](#image-cropping)

[![Cropping](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/cropping.gif)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/cropping.gif)

By default you are able to crop / rotate images by clicking the scissors in the left bottom corner on the edit view. The [vue-js-clipper](https://github.com/timtnleeProject/vuejs-clipper) is used for this purpose. The cropping feature is limited to mime type of `image/jpg`, `image/jpeg` and `image/png`.

**Important:** By cropping an existing image the original media model is deleted and replaced by the cropped image. All custom properties are copied form the old to the new model.

To disable this feature use the `croppable` method:

```
Images::make('Gallery')->croppable(false);
```

You can set all configurations like ratio e.g. as following:

```
Images::make('Gallery')->croppingConfigs(['ratio' => 4/3]);
```

Available cropping configuration, see .

It is possible to enforce cropping on upload, for example to ensure the image has the set aspect ratio:

```
Images::make('Gallery')->mustCrop();
```

Custom properties
-----------------

[](#custom-properties)

[![Custom properties](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/custom-properties.gif)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/custom-properties.gif)

```
Images::make('Gallery')
    ->customPropertiesFields([
        Boolean::make('Active'),
        Markdown::make('Description'),
    ]);

Files::make('Multiple files', 'multiple_files')
    ->customPropertiesFields([
        Boolean::make('Active'),
        Markdown::make('Description'),
    ]);

// custom properties without user input
Files::make('Multiple files', 'multiple_files')
    ->customProperties([
        'foo' => auth()->user()->foo,
        'bar' => $api->getNeededData(),
    ]);
```

Show image statistics *(size, dimensions, type)*
------------------------------------------------

[](#show-image-statistics-size-dimensions-type)

[![Image statistics](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/show-statistics.png)](https://raw.githubusercontent.com/ebess/advanced-nova-media-library/master/docs/show-statistics.png)

```
Images::make('Gallery')
    ->showStatistics();
```

Custom headers
--------------

[](#custom-headers)

```
Images::make('Gallery')
    ->customHeaders([
        'header-name' => 'header-value',
    ]);
```

Media Field (Video)
-------------------

[](#media-field-video)

In order to handle videos with thumbnails you need to use the `Media` field instead of `Images`. This way you are able to upload videos as well.

```
use Ebess\AdvancedNovaMediaLibrary\Fields\Media;

class Category extends Resource
{
    public function fields(Request $request)
    {
        Media::make('Gallery') // media handles videos
            ->conversionOnIndexView('thumb')
            ->singleMediaRules('max:5000'); // max 5000kb
    }
}

// ..

class YourModel extends Model implements HasMedia
{
    public function registerMediaConversions(Media $media = null)
    {
        $this->addMediaConversion('thumb')
            ->width(368)
            ->height(232)
            ->extractVideoFrameAtSecond(1);
    }
}
```

Temporary Urls
--------------

[](#temporary-urls)

If you are using Amazon S3 to store your media, you will need to use the `temporary` function on your field to generate a temporary signed URL. This function expects a valid Carbon instance that will specify when the URL should expire.

```
Images::make('Image 1', 'img1')
    ->temporary(now()->addMinutes(5))

Files::make('Multiple files', 'multiple_files')
    ->temporary(now()->addMinutes(10),

```

**Note**: This feature does not work with the existing media feature.

Credits
=======

[](#credits)

- [nova media library](https://github.com/jameslkingsley/nova-media-library)

Alternatives
============

[](#alternatives)

- [dmitrybubyakin/nova-medialibrary-field](https://github.com/dmitrybubyakin/nova-medialibrary-field)

###  Health Score

31

—

LowBetter than 70% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~58 days

Total

39

Last Release

1546d ago

Major Versions

0.2.1 → 1.0.02018-10-19

1.2.0 → 2.0.02018-12-19

2.9.1 → 3.0.02020-04-05

PHP version history (2 changes)0.1.1PHP &gt;=7.1.0

3.3.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a728b47a1ee9fd11f949888a6de60971bbeaf3057d022eab6a6e50491089b4b?d=identicon)[kayacekovic](/maintainers/kayacekovic)

---

Top Contributors

[![ebess](https://avatars.githubusercontent.com/u/5565003?v=4)](https://github.com/ebess "ebess (70 commits)")[![GarethSomers](https://avatars.githubusercontent.com/u/5942607?v=4)](https://github.com/GarethSomers "GarethSomers (26 commits)")[![sietzekeuning](https://avatars.githubusercontent.com/u/11088108?v=4)](https://github.com/sietzekeuning "sietzekeuning (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![ibrahim-mubarak](https://avatars.githubusercontent.com/u/47777720?v=4)](https://github.com/ibrahim-mubarak "ibrahim-mubarak (10 commits)")[![0xb4lint](https://avatars.githubusercontent.com/u/3747631?v=4)](https://github.com/0xb4lint "0xb4lint (5 commits)")[![kayacekovic](https://avatars.githubusercontent.com/u/32109756?v=4)](https://github.com/kayacekovic "kayacekovic (5 commits)")[![bkintanar](https://avatars.githubusercontent.com/u/685928?v=4)](https://github.com/bkintanar "bkintanar (4 commits)")[![petyots](https://avatars.githubusercontent.com/u/14016592?v=4)](https://github.com/petyots "petyots (4 commits)")[![batFormat](https://avatars.githubusercontent.com/u/13119245?v=4)](https://github.com/batFormat "batFormat (4 commits)")[![milewski](https://avatars.githubusercontent.com/u/2874967?v=4)](https://github.com/milewski "milewski (3 commits)")[![blocklogic-au](https://avatars.githubusercontent.com/u/1908481?v=4)](https://github.com/blocklogic-au "blocklogic-au (3 commits)")[![bernhardh](https://avatars.githubusercontent.com/u/642292?v=4)](https://github.com/bernhardh "bernhardh (3 commits)")[![ragingdave](https://avatars.githubusercontent.com/u/1168344?v=4)](https://github.com/ragingdave "ragingdave (2 commits)")[![niekbr](https://avatars.githubusercontent.com/u/10487997?v=4)](https://github.com/niekbr "niekbr (2 commits)")[![happyDemon](https://avatars.githubusercontent.com/u/38573?v=4)](https://github.com/happyDemon "happyDemon (2 commits)")[![danielztolnai](https://avatars.githubusercontent.com/u/15679094?v=4)](https://github.com/danielztolnai "danielztolnai (2 commits)")[![Livijn](https://avatars.githubusercontent.com/u/349311?v=4)](https://github.com/Livijn "Livijn (2 commits)")[![shirshak55](https://avatars.githubusercontent.com/u/8097377?v=4)](https://github.com/shirshak55 "shirshak55 (1 commits)")[![CaddyDz](https://avatars.githubusercontent.com/u/13698160?v=4)](https://github.com/CaddyDz "CaddyDz (1 commits)")

---

Tags

laravelnova

### Embed Badge

![Health badge](/badges/kayacekovic-advanced-nova-media-library/health.svg)

```
[![Health](https://phpackages.com/badges/kayacekovic-advanced-nova-media-library/health.svg)](https://phpackages.com/packages/kayacekovic-advanced-nova-media-library)
```

###  Alternatives

[ebess/advanced-nova-media-library

Laravel Nova tools for managing the Spatie media library.

6133.3M20](/packages/ebess-advanced-nova-media-library)[stepanenko3/nova-cards

A Laravel Nova info cards.

33141.0k](/packages/stepanenko3-nova-cards)[pos-lifestyle/laravel-nova-date-range-filter

A Laravel Nova date range filter.

16178.1k](/packages/pos-lifestyle-laravel-nova-date-range-filter)

PHPackages © 2026

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