Laravel-Backpack / medialibrary-uploaders

MIT License
9 stars 3 forks source link

Changes #1

Closed tabacitu closed 1 year ago

tabacitu commented 1 year ago

Todos:

So in the end, the syntax can be used like this:


CRUD::field('images')->withMedia(); // will use Backpack defaults for everything

// or

CRUD::field('images')->withMedia([ // customize some or all of the Backpack defaults
            'collection' => 'my_collection',
            'disk'       => 'my_disk',
            'name'       => 'my_media',
            'saving'     => (function($media, $field) {
                // Note 1: this method can only be called AFTER withMedia()
                // Note 2: $media is a RestrictedSpatieMedia which extends SpatieMedia but prevents 
                // setDisk(), setCollection(), mediaName() and toMediaCollection()

                $media->thumbnail();
                return $media;

                // Note 3: the return type MUST BE RestrictedSpatieMedia, NOT whatever it is after calling toMediaCollection()
            })
        ]);
tabacitu commented 1 year ago

Let's