PHP code example of mlsolutions / nova-media-field

1. Go to this page and download the library: Download mlsolutions/nova-media-field library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mlsolutions / nova-media-field example snippets


use Mlsolutions\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(['      ->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(['

use Mlsolutions\NovaMediaField\Fields\Thumbnail;

Thumbnail::make('Miniatura', fn () => $authorizedPreviewUrl)
    ->altText($accessibleDescription)
    ->fallbackText('Prévia indisponível')
    ->dimensions(64, 64)
    ->onlyOnIndex(),

// app/Providers/NovaServiceProvider.php

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

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