Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages

Readme

Nova Media Field

Latest Version on Packagist Total Downloads License

screenshot of field

Description

A Laravel Nova field for laravel-medilibrary.

Features

  • Multiple / Single image support
  • Multiple images auto-detect based on collection
  • Display validation errors
  • Show on index multiple images
  • Modal with media details
  • Show all conversions
  • Open / Download / Copy URL of media
  • Regenerate image with conversions
  • Custom properties support

Requirements

  • php: >=8.0
  • laravel/nova: ^4.0
  • spatie/laravel-medilibrary: ^11.4

Installation

# Install the package
composer require stepanenko3/nova-media-field

Usage

use use Stepanenko3\NovaMediaField\Fields\Media;
...

Media::make(__('Image'), 'image'), // Single image. Auto detect from collection

Media::make(__('Images'), 'images'), // Multiple images. Auto detect from collection

// Validation rules

Media::make('Images', 'images')
    ->rules(['required', 'array', 'max:4'])
    ->singleMediaRules(['image', 'max:80']),


// Custom properties with validtion

Media::make('Images', 'images')
    ->customPropertiesFields([
        Boolean::make('Active', 'active')
            ->rules(['boolean']),

        Markdown::make('Description', 'description')
            ->rules(['max:1000']),
    ])


// Count images displayed on index

Media::make('Images', 'images')
    ->countOfImagesDisplayedOnIndex(2),


// Full example

Media::make('Images', 'images')
    ->customPropertiesFields([
        Boolean::make('Active', 'active')
            ->rules(['boolean']),

        Markdown::make('Description', 'description')
            ->rules(['max:1000']),
    ])
    ->countOfImagesDisplayedOnIndex(2)
    ->rules(['required', 'array', 'max:4'])
    ->singleMediaRules(['image', 'max:80']),

Usage with File Manager

Install stepanenko3/nova-filemanager

compore require stepanenko3/nova-filemanager

Register Service provider

// app/Providers/NovaServiceProvider.php

public function tools(): array
{
    return [
        new Stepanenko3\NovaFileManager\FileManagerTool,
    ];
}

Use Media field with File Manager

Media::make(__('Image'), 'image')
    ->fileManager(),

Screenshots

screenshot of field screenshot of field screenshot of field screenshot of field screenshot of field screenshot of field

Credits

Contributing

Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.

License

This package is open-sourced software licensed under the MIT license.

Back to Top
Added 2 years ago
Last updated 1 Year Ago
Version v3.0.1
Nova Version ^4.22
Composer
stepanenko3/nova-media-field
GitHub stars 17
Packagist downloads 17,100

Favorites

1 user favorited

Rating

5.00
(out of 5)
★★★★★
★★★★
★★★
★★
1 ratings

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas