Download the PHP package jameslkingsley/nova-media-library-field without Composer
On this page you can find all versions of the php package jameslkingsley/nova-media-library-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jameslkingsley/nova-media-library-field
More information about jameslkingsley/nova-media-library-field
Files in jameslkingsley/nova-media-library-field
Package nova-media-library-field
Short Description Laravel Nova tools for managing the Spatie media library.
License MIT
Informations about the package nova-media-library-field
Laravel Nova Media Library
Attention: Please consider using this package instead, it has a lot more support for various medialibrary features, and will probably fit your needs better!
This package is designed to be used with the awesome media library package from Spatie. With this package you can add an image field for uploading single files to a resource, a generic file field for other types, and add an images field to resources to display all of their associated media.
In this example we're defining a field called Avatar
that uses the avatar
collection. It's also calling usingConversion
to set the thumb
conversion as the image to be displayed (on detail and index). The other methods called are dynamically applied to the upload request - this lets you call any media-library method on the field..
If you want it to remove the old image before uploading the new one, be sure to make your model's media collection a single file collection.
When you want to upload a file that isn't an image, you can use the rudimentary File
field included with this package. It follows the same format as registering an Image
field.
That's all there is to it! The rest of the configuration should be done in the media collection itself, such as:
To show all media records for your resource simply add the Images
field like so:
This will automatically use the media
attribute on your model (which the HasMediaTrait
adds).
Note: You currently cannot create media directly from Nova.
Registering the media resource
If you'd like to use the media resource included with this package, you need to register it manually in your NovaServiceProvider
in the boot
method.