PHPackages                             maxim-drobonoh/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. [Image &amp; Media](/categories/media)
4. /
5. maxim-drobonoh/nova-media-library

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

maxim-drobonoh/nova-media-library
=================================

Tool and field that will let you managing files and add them to the posts

1.0.4(5y ago)02MITPHPPHP &gt;=7.1.0

Since Jun 19Pushed 5y agoCompare

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

READMEChangelogDependencies (1)Versions (16)Used By (0)

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

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

Tool and Field for [Laravel Nova](https://nova.laravel.com) that will let you managing files and add them to the posts.

##### Table of Contents

[](#table-of-contents)

- [Features](#features)
- [Migration from 0.x to 1.x](#migration-from-0x-to-1x)
- [Requirements](#requirements)
- [Install](#install)
- [Configuration](#configuration)
- [Usage](#usage)
- [Customization](#customization)
- [Upload by url or path](#upload-by-url-or-path)
- [Get files by ids](#get-files-by-ids)
- [Private files](#private-files)
- [Localization](#localization)
- [Screenshots](#screenshots)

### Features

[](#features)

- Store and manage your media files
- Use field for single file
- Use field for array of files
- Upload files by url/path
- Integrate Media Field with Trix editor
- Implement custom JS callback for field
- Automatic resize image on the backend by width\\height
- Cropping image on the frontend
- Ability to create image size variations
- Organize files in single folder, separate by date or by manageable folders
- Ability to control files visibility

### Migration from 0.x to 1.x

[](#migration-from-0x-to-1x)

In version 1.x, the configuration file and database migration have been changed.
After upgrading to version 1.x, you need to remove the old table from the database, then reinstall and reconfigure these files.

### Requirements

[](#requirements)

- Laravel 5.8+
- Nova 2
- [intervention/image](http://image.intervention.io) package for image resizing (optional)

### Install

[](#install)

```
composer require classic-o/nova-media-library

php artisan vendor:publish --provider="ClassicO\NovaMediaLibrary\ToolServiceProvider"

php artisan migrate

php artisan storage:link

```

### Configuration

[](#configuration)

[See configuration file](https://github.com/classic-o/nova-media-library/blob/master/config/nova-media-library.php)

### Usage

[](#usage)

Add tool in app/Providers/NovaServiceProvider.php

```
public function tools()
{
    return [
        new \ClassicO\NovaMediaLibrary\NovaMediaLibrary()
    ];
}

```

Add Field to the resource.

```
use ClassicO\NovaMediaLibrary\MediaLibrary;

class Post extends Resource
{
    ...
     public function fields(Request $request)
        {
            return [
                ...
                MediaLibrary::make('Image'),
                ...
            ];
        }
    ...
}

```

### Customization

[](#customization)

By default, this field is used as single file. If you need to use as array of files, add option:

```
# Display
MediaLibrary::make('Gallery')
            ->array(),

```

By default this files display automatically, `gallery` or `list` as in tool.
You can set in first parameter needed display type:

```
MediaLibrary::make('Documents')
            ->array('list'),

```

*When you use array, set the casts as array to needed column in model and set type `nullable TEXT` in database*
*For single file - `nullable INT`*

If you want to hide files under the accordion, add the following option:

```
MediaLibrary::make('Gallery')
            ->array()
            ->hidden()

```

You can limit the selection of files by type (Labels of types from configuration file).

```
MediaLibrary::make('File')
            ->types(['Audio', 'Video'])

```

To set preview size of images in fields, add the following option (Label of cropped additional image variation)
By default, the preview size is set in the configuration file.

```
MediaLibrary::make('File')
            ->preview('thumb')

```

You can also integrate the Media Field with the Trix editor. You need to set a unique name in the `trix` option and add an additional attribute with the same name in the Trix field:

```
MediaLibrary::make('For Trix')
            ->trix('unique_trix_name'),

Trix::make('Content')
    ->withMeta([ 'extraAttributes' => [ 'nml-trix' => 'unique_trix_name' ] ])

```

For set a custom callback for the Media Field, use the method `jsCallback`.

- The first parameter set as the name of the JS function callback.
- The second (optional) is an array of advanced options

```
MediaLibrary::make('JS Callback')
	        ->jsCallback('callbackName', [ 'example' => 'Nova' ]),

```

Your JavaScript callback should have 2 parameters. The first will be an array of files, second - your options.

```
window.callbackName = function (array, options) {
  console.log(array, options);
}

```

*When you use JS Callback or Trix option two or more times on one resource, set second parameter of make method to any unique name*

```
MediaLibrary::make('JS Callback', 'js_cb_name_1')
	        ->jsCallback('callbackName', [ 'example' => 'Nova' ]),
MediaLibrary::make('Trix Field', 'trix_name_1')
	        ->trix('unique_trix_name'),

```

### Upload by url or path

[](#upload-by-url-or-path)

Also you can programmatically add files to the media library by url or path.

```
use \ClassicO\NovaMediaLibrary\API;

$result = API::upload('https://pay.google.com/about/static/images/social/og_image.jpg');

```

If upload done successfully, function return instance of model.
If an error occurred while loading, function will throw exception.

Exceptions (`code => text`):
`0` - `The file was not downloaded for unknown reasons`
`1` - `Forbidden file format`
`2` - `File size limit exceeded`

### Get files by ids

[](#get-files-by-ids)

In your model stores only id of file(s). To get files, use the API class method:

```
$files = API::getFiles($ids, $imgSize = null, $object = false);

# First parameter - id or array of ids
# Second - if you want to get images by size variation, write label of size
# Third - by default function return array of urls. If you want to get full data of files - set true (returns object / array of objects)

```

### Private files

[](#private-files)

When you use local storage or s3 (with private visibility), you can't get files by url.
To get file, you need to create a GET Route with the name `nml-private-file` with parameter `id` and optional `img_size`. In controller add validation user access.
If access is allowed, you can get file by API method:

```
... Verifying access

$file = API::getFiles($id, null, true);
return API::getPrivateFile($file->path, request('img_size'))

```

### Localization

[](#localization)

To translate this tool another language, you need to add the translation file `/resources/lang/vendor/nova-media-library/{lang}.json` by adding phrases from [en.json](https://github.com/classic-o/nova-media-library/tree/master/resources/lang/en.json)

### Screenshots

[](#screenshots)

[![Media Library](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_1.png)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_1.png)

[![Media Library](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_2.png)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_2.png)

[![Details](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_3.png)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_3.png)

[![Crop Image](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_4.png)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_4.png)

[![Index Field](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_5.png)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_5.png)

[![Form Field](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_6.png)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/screenshot_6.png)

[![Record](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/record.gif)](https://raw.githubusercontent.com/classic-o/nova-media-library/master/docs/record.gif)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~33 days

Recently: every ~62 days

Total

15

Last Release

2056d ago

Major Versions

0.5.4 → 1.0.02020-01-19

### Community

Maintainers

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

---

Top Contributors

[![classic-o](https://avatars.githubusercontent.com/u/48679437?v=4)](https://github.com/classic-o "classic-o (38 commits)")[![nibri10](https://avatars.githubusercontent.com/u/22533877?v=4)](https://github.com/nibri10 "nibri10 (3 commits)")[![bastihilger](https://avatars.githubusercontent.com/u/1419634?v=4)](https://github.com/bastihilger "bastihilger (1 commits)")[![maxim-drobonoh](https://avatars.githubusercontent.com/u/28189512?v=4)](https://github.com/maxim-drobonoh "maxim-drobonoh (1 commits)")[![pxlrbt](https://avatars.githubusercontent.com/u/22632550?v=4)](https://github.com/pxlrbt "pxlrbt (1 commits)")[![Jebble](https://avatars.githubusercontent.com/u/1397260?v=4)](https://github.com/Jebble "Jebble (1 commits)")[![E-Liegeois](https://avatars.githubusercontent.com/u/75976679?v=4)](https://github.com/E-Liegeois "E-Liegeois (1 commits)")

---

Tags

laravelmediagallerynova

### Embed Badge

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

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

###  Alternatives

[classic-o/nova-media-library

Tool and field that will let you managing files and add them to the posts

154172.0k](/packages/classic-o-nova-media-library)[mostafaznv/nova-ckeditor

CkEditor for Laravel Nova

57327.2k1](/packages/mostafaznv-nova-ckeditor)[silvanite/nova-field-cloudinary

A Laravel Nova Image Field with Flysystem Adapter for storing and retrieving media from Cloudinary

2772.0k3](/packages/silvanite-nova-field-cloudinary)[stepanenko3/nova-media-field

A Laravel Nova field for laravel-medilibrary.

1717.5k](/packages/stepanenko3-nova-media-field)[webplusm/gallery-json-media

a filament media storing in a Json field

196.0k](/packages/webplusm-gallery-json-media)[mariojgt/witchcraft

A Laravel Package Witchcraft, a quick start for new laravel Packages

312.6k](/packages/mariojgt-witchcraft)

PHPackages © 2026

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