This Laravel Nova package allows you to manage media and media fields

Overview

Nova Media Hub

Latest Version on Packagist Total Downloads

This Laravel Nova package allows you to manage media and media fields.

Requirements

  • php: >=8.0
  • laravel/nova: ^4.0

Features

  • Media Hub UI in separate view
  • Media Hub field for selecting single/multiple media
  • Image optimization and multiple conversions support
  • File naming and path making customization
  • Dark mode support
  • A lot configuration options

Screenshots

Media Hub

Choose media

Installation

Install the package in a Laravel Nova project via Composer and run migrations:

# Install nova-media-hub
composer require outl1ne/nova-media-hub

# Run migrations
php artisan migrate

Register the tool with Nova in the tools() method of the NovaServiceProvider:

// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        new \Outl1ne\NovaMediaHub\MediaHub
    ];
}

Usage

Fields

This package provides a field MediaHubField which allows you to select media. This saves the media as a JSON array into the database.

Example usage:

multiple(), // Define whether multiple media can be selected">
use Outl1ne\NovaMediaHub\Nova\Fields\MediaHubField;

// ...

MediaHubField::make('Media', 'media')
  ->defaultCollection('products') // Define the default collection the "Choose media" modal shows
  ->multiple(), // Define whether multiple media can be selected

Configure

The config file can be published using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaMediaHub\MediaHubServiceProvider" --tag="config"

Localization

The translation file(s) can be published by using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaMediaHub\MediaHubServiceProvider" --tag="translations"

Credits

License

Nova Media Hub is open-sourced software licensed under the MIT license.

Comments
  • fix: multiple field display & switch collection

    fix: multiple field display & switch collection

    For anyone who wants to have quick fix before merge.

    # composer.json
    
    {
        "require": {
            // ...
            "outl1ne/nova-media-hub": "dev-main",
        },
        "repositories": {
            // ...
            "nova-media-hub": {
                "type": "vcs",
                "url": "https://github.com/godkinmo/nova-media-hub.git"
            }
        }
    }
    

    Then

    composer require outl1ne/nova-media-hub:dev-main
    
    opened by godkinmo 7
  • Can't upload files via MediaHubField

    Can't upload files via MediaHubField

    Hello, I'm not sure if this is intended or not. But there is no way to upload files directly from the resource. I'm using version 1.4.1 and this is what I see (https://imgur.com/a/VSpBP82) Can anyone confirm if this is intended ?

    opened by marcelosantos89 5
  • Your requirements could not be resolved to an installable set of packages

    Your requirements could not be resolved to an installable set of packages

    can't install it , i got the follwing error when run composer require outl1ne/nova-media-hub


    Your requirements could not be resolved to an installable set of packages.

    Problem 1 - outl1ne/nova-media-hub[1.0.0, ..., 1.0.2] require outl1ne/nova-translatable 2.0.4 -> found outl1ne/nova-translatable[2.0.4] but the package is fixed to 2.0.6 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. - outl1ne/nova-media-hub[1.0.3, ..., 1.0.5] require spatie/image ^2.2 -> found spatie/image[2.2.0, ..., 2.2.4] but the package is fixed to 1.10.6 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. - Root composer.json requires outl1ne/nova-media-hub ^1.0 -> satisfiable by outl1ne/nova-media-hub[1.0.0, ..., 1.0.5].

    Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions. You can also try re-running composer require with an explicit version constraint, e.g. "composer require outl1ne/nova-media-hub:*" to figure out if any version is installable, or "composer require outl1ne/nova-media-hub:^2.1" if you know which you need.

    Installation failed, reverting ./composer.json and ./composer.lock to their original content.

    opened by MA7MOUDAL3RABY 3
  • Fix the problem with trimmed file name

    Fix the problem with trimmed file name

    Theres is a problem when media is created from a remote source. The last character of the original file name is trimmed.

    To reproduce the issue run in a console:

    php artisan tinker

    and then enter:

    \Outl1ne\NovaMediaHub\MediaHub::storeMediaFromUrl('https://picsum.photos/1920/1080.jpg', 'default');

    As a result a new file with wrong filename (108.jpg instead of 1080.jpg) is saved: image

    That's because files saved in /tmp directory don't have an extension.

    opened by michalsrodek 2
  • any file validation?

    any file validation?

    Hi,

    I like this project you've built, but before I can implement it I have a question which I could not find any answers in the documentation or code:

    Is there any way to perform validation on the files being uploaded? I would like to limit the filetypes being uploaded, add our own custom file rules, perform virus scan on uploads etc.

    As example someone now can easily upload a test.php with the following script:

    <?php
    
    echo phpinfo();
    

    after uploading and the uploading folder is set to public, anyone can go to the url of that file and get all php info of the server.

    If it doesn't exist yet, it would be awesome to add in the config/nova-media-hub.php something like the following:

    return [
        //...
    
        'file_validation' => [
            '*' => [ // any collection
                'file',
                'max:5000',
                'mimes:doc,xls,jpg,png,svg,pdf'
                MyCustomRule::class,
                // array of validation rules like you would normally have in laravel
            ],
            'images' => [ // validation just for this collection
                 'image'
            ]
        ]
    ];
    
    opened by wjstraver 2
  • Search problem

    Search problem

    Screenshot 2022-12-10 at 00 20 03

    It would be better if "upper" is replaced by "lower" and unicode search problem will be resolved.

    For example, if Text Title (or any field in data column) is "ტესტ", search doesn't work.

    opened by nickjangveladze 1
  • Remove double URL encoding

    Remove double URL encoding

    We noticed that filenames for uploaded images are being double-url-encoded - for instance File-(2).jpg was decoded as File-%25282%2529.jpg instead of File-%282%29.jpg.

    This is due to the ->url() method of Storage already URL-encoding.

    This PR removes the double encoding, producing working URLs again.

    opened by SteJaySulli 1
  • Behavior concern: delete file on copyFileToMediaLibrary

    Behavior concern: delete file on copyFileToMediaLibrary

    Hi, thanks for the great package !

    I'm using your MediaHub::fileHandler to seed a new database from existing files.

    MediaHub::fileHandler()            
        ->withFile($questions_audios->path($question['id_audio_fr'] . '.mp3'))
        ->withCollection('question_audio')
        ->save();
    

    But the save() method deletes the original files by default: $this->filesystem->copyFileToMediaLibrary($this->pathToFile, $media, $this->fileName, Filesystem::TYPE_ORIGINAL, **true**);

    I'm wondering if this is the wanted behavior and if it should not be false by default ? I didn't lose any files but can imagine someone getting bit by this particular situation.

    If this is the desired behavior on your side, should it be possible to modify it slightly to delete but on demand ? Like maybe :

    protected string $removeOnSave = false;
    
    public function removeOnSave(bool $removeOnSave)
    {
        $this->removeOnSave = $removeOnSave;
        return $this;
    }
    
    $this->filesystem->copyFileToMediaLibrary($this->pathToFile, $media, $this->fileName, Filesystem::TYPE_ORIGINAL, $this->removeOnSave);
    

    Then we could use it like this:

    MediaHub::fileHandler()            
        ->withFile($questions_audios->path($question['id_audio_fr'] . '.mp3'))
        ->withCollection('question_audio')
        **->removeOnSave(true)**
        ->save();
    

    Cheers !

    opened by NessterGit 1
  • Caption & Copyright Fields / Search in data / IT Lang

    Caption & Copyright Fields / Search in data / IT Lang

    Working in the field of digital publishing, we needed to adapt the code of your excellent extension with internal needs.

    I have tried to keep the changes to a minimum.

    If it is to your liking you can accept the PR, which consists of:

    • Copyright and Caption support: especially in asset recycling it is widely used.
    • Italian translation: as per voice
    • Show image ID: in our case it is used to interface the asset with an encoder of the asset
    • Search within metadata: since we cannot change the filename we felt the best way is to search within the alt text (but when in doubt in any field)

    Thanks for your attention and good work :)

    opened by murdercode 1
  • encode issue

    encode issue

    Hi! Haven't you noticed that the encode function wreak the file path? It changes slashes to %2F in paths. Instead of return urlencode(urldecode($fileName)); I do return dirname($fileName)."/".urlencode(urldecode(basename($fileName)));

    opened by Brand3000 1
  • how to customize return value

    how to customize return value

    hi, I am using Inertia js, I need to customize the returned value instead of "image id" -> "https://mydomain.com/media"file system drive"/projects"collection name"/project.png"image name not ID"

    Is it possible to achieve that?

    opened by MA7MOUDAL3RABY 1
Releases(1.5.1)
  • 1.5.1(Dec 14, 2022)

  • 1.5.0(Dec 12, 2022)

    NB! Breaking change - file names are no longer automagically encoded. This should fix default adapters, but might cause issues with third-party adapters or if you use Thumbor.

    Added

    • Added deleteOriginal(true/false) option to FileHandler
    • Added format option to conversions config

    Changed

    • Fixed file naming issue with remote files (thanks to @michalsrodek)
    • File names are no longer double encoded with default drivers (thanks to @SteJaySulli)
    • Changed search case insensitivity with LOWER() (instead of UPPER())
    • Improved UploadedFile error handling and displaying
    • Fixed "system" dark mode setting not always setting correct colour
    • Improved media hub view responsiveness
    • Updated packages
    Source code(tar.gz)
    Source code(zip)
  • 1.4.2(Nov 29, 2022)

  • 1.4.1(Nov 9, 2022)

  • 1.4.0(Nov 9, 2022)

  • 1.3.1(Nov 8, 2022)

  • 1.3.0(Nov 2, 2022)

    Added

    • Added withCustomFields() to MediaHub Tool which allows adding custom data fields for media items
    • Added quick upload to "choose media" modal (thanks to @ndrez-outl1ne)
    • Added media ID to MediaItem component (thanks to @murdercode)
    • Added Italian translations (thanks to @murdercode)

    Changed

    • Fetch more images per page (now 72 per page, instead of 18) (thanks to @ndrez-outl1ne)
    • Choose media modal is now full-screen and the media items list is scrollable (thanks to @ndrez-outl1ne)
    • Selected media items now scroll horizontally instead of wrapping (thanks to @ndrez-outl1ne)
    • Allow searching items by their data fields (thanks to @murdercode)
    • Clicking on a MediaItem component's file name now opens view/edit modal for quick access
    • Misc UI fixes (reduced media items size in some places)
    • Updated packages
    Source code(tar.gz)
    Source code(zip)
  • 1.2.8(Oct 21, 2022)

    Added

    • Added option to configure image conversion driver
    • Added hideFromMenu() to MediaHub Tool

    Changed

    • Report file upload errors via Laravel's report() helper
    Source code(tar.gz)
    Source code(zip)
  • 1.2.7(Oct 13, 2022)

  • 1.2.6(Oct 13, 2022)

    Changed

    • Refactored RemoteFile to use Http instead of file_get_contents to improve compatibility with different servers and redirects
    • Refactored RemoteFile disk to disk copying to use streams
    Source code(tar.gz)
    Source code(zip)
  • 1.2.5(Oct 4, 2022)

  • 1.2.4(Sep 26, 2022)

  • 1.2.3(Sep 26, 2022)

  • 1.2.2(Sep 26, 2022)

  • 1.2.1(Sep 21, 2022)

  • 1.2.0(Sep 21, 2022)

    Added

    • FileHandler now encodes file names.
      • This is backwards compatible, since we will avoid double encoding.
      • New files will now be urlencoded using php's urlencode
    • OrderBy and Search filters
    Source code(tar.gz)
    Source code(zip)
  • 1.1.6(Sep 19, 2022)

  • 1.1.5(Sep 12, 2022)

  • 1.1.4(Sep 6, 2022)

    Changed

    • Append array values to formData with index
      • Fixes an issue when using alongside other packages that don't respect data[] key, but instead want data[0...n]
    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Sep 6, 2022)

    Changed

    • Fixed issue with "Move to collection" confirmation modal getting stuck on loading state
    • Improved deduplication handling in the UI
    • Updated packages
    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(Aug 25, 2022)

  • 1.1.1(Aug 25, 2022)

  • 1.1.0(Aug 25, 2022)

    Added

    • Added file deduplication via original file hash
    • Added file name to MediaItem component

    Changed

    • Fixed cloud storage support for file processing
    • Fixed cloud storage directory count calculation
    • Filesystem refactoring and misc improvements
    • Fixed missing formatForNova data
    • Fixed data fields UI in media view modal
    Source code(tar.gz)
    Source code(zip)
  • 1.0.7(Aug 24, 2022)

  • 1.0.6(Aug 24, 2022)

    Changed

    • Fixed Media model incorrect references (thanks to @vodnicearv)
    • Mark selected media items with a checkmark instead of hiding them
    • Fixed overriding of toArray breaking Nova UI when overriding configurable media model
    • Fixed inertia navigation crashing after using a context menu
    • Updated packages
    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Aug 17, 2022)

  • 1.0.4(Aug 9, 2022)

  • 1.0.3(Aug 1, 2022)

  • 1.0.2(Jul 19, 2022)

    Changed

    • Fixed MediaItem long file name overflow
    • Fixed context menu not working as expected when having multiple MediaHub fields on the same resource
    • Fixed context menu positioning on scrollable pages
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Jul 19, 2022)

    Changed

    • Fixed path generation (thanks to @godkinmo)
    • Fixed hasValue and fill() functions not working with empty values (thanks to @godkinmo)
    • Fixed non-casted array attributes not showing selected media after saving
    • Selected media count is now shown in the choose media modal
    • Fixed conversions and empty directories not being deleted after deleting media
    • Fixed file name overflow in the view media modal
    • Updated packages
    Source code(tar.gz)
    Source code(zip)
Owner
outl1ne
Digital product agency based in Tallinn, Estonia.
outl1ne
This Laravel Nova settings tool based on env, using nativ nova fields and resources

Nova Settings Description This Laravel Nova settings tool based on env, using nativ nova fields and resources Features Using native Nova resources Ful

Artem Stepanenko 21 Dec 28, 2022
This Laravel Nova tool lets you run artisan and bash commands directly from Nova 4 or higher.

Laravel Nova tool for running Artisan & Shell commands. This Nova tool lets you run artisan and bash commands directly from nova. This is an extended

Artem Stepanenko 17 Dec 15, 2022
Makes working with DateTime fields in Laravel's Nova easier

This package adds a DateTime field with support for a global DateTime format, syntactic sugar for formatting individual DateTime fields and powerful d

wdelfuego 6 Aug 4, 2022
This repo is for the Laracon 2021 talk "Manage SEO with Laravel and Nova"

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Kristin 7 Dec 9, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.9k Jan 2, 2023
This tool gives you the ability to set the default collapse state for Nova 4.0 menu items.

Nova Menu Collapsed This tool gives you the ability to set the default collapse state for Nova 4.0 menu items. Requirements php: >=8.0 laravel/nova: ^

Artem Stepanenko 10 Nov 17, 2022
A laravel package to handle model specific additional meta fields in an elegant way.

Laravel Meta Fields A php package for laravel framework to handle model meta data in a elegant way. Installation Require the package using composer: c

Touhidur Rahman 26 Apr 5, 2022
Laravel Nova Ban simplify blocking and banning Eloquent models.

Laravel Nova Ban Introduction Behind the scenes cybercog/laravel-ban is used. Contents Installation Usage Prepare bannable model Prepare bannable mode

cybercog 39 Sep 29, 2022
🖼️ Laravel Nova Field for uploading and cropping images using Slim Image Cropper

??️ Laravel Nova Field for uploading and cropping images using Slim Image Cropper

Marius 5 Apr 2, 2022
Laravel Nova filter for Spatie/laravel-tags

SpatieTagsNovaFilter This package allows you to filter resources by tags. (using the awesome Spatie/laravel-tags and Vue-MultiSelect ) Installation Fi

Mahi-Mahi 3 Aug 4, 2022
⚙️Laravel Nova Resource for a simple key/value typed setting

Laravel Nova Resource for a simple key/value typed setting Administer your Laravel Simple Setting in Nova Pre-requisites This Nova resource package re

elipZis 5 Nov 7, 2022
A customisable Laravel Nova card that fetches data through ajax calls.

Ajax Table Card Description A customisable Laravel Nova card that fetches data through ajax calls. Why? To allow displaying certain data on the dashbo

TwentyOne34 Technologies Corp. 4 Mar 8, 2022
Webhook Manager for Laravel Nova

Webhook Manager for Laravel Nova A Laravel Nova tool that allows users to create and manage webhooks based on Eloquent Model events. A tool for Larave

Doug Niccum 9 Dec 27, 2022
A minimalistic event calendar Tool for Laravel's Nova 4

Event calendar for Laravel Nova 4 An event calendar that displays Nova resources or other time-related data in your Nova 4 project on a monthly calend

wdelfuego 44 Jan 1, 2023
A Laravel Nova tool for viewing your application logs

This package makes it easy to view your Laravel application logs inside of Nova. It even supports polling. Installation You can install the Nova tool

The Laravel Framework 117 Dec 11, 2022
Laravel Nova's Queued Export As CSV Action

Laravel Nova's Queued Export As CSV Action Installation To install through composer, run the following command from terminal: composer require "nova-k

null 9 Dec 15, 2022
Laravel Livewire form component with declarative Bootstrap 5 fields and buttons.

Laravel Livewire Forms Laravel Livewire form component with declarative Bootstrap 5 fields and buttons. Requirements Bootstrap 5 Installation composer

null 49 Oct 29, 2022
Laravel Livewire (TALL-stack) form generator with realtime validation, file uploads, array fields, blade form input components and more.

TALL-stack form generator Laravel Livewire, Tailwind forms with auto-generated views. Support Contributions Features This is not an admin panel genera

TinaH 622 Jan 2, 2023
Base library for repeated layout fields, content builders and other collection components

laravel-flexible-content This package's only purpose is to build custom repeated layout components, such as Laravel Nova's Flexible Content field or y

Whitecube 5 May 31, 2022