alberto-bottarini / nova-image-with-thumbs
A Laravel Nova field.
Installs: 1 035
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-10-29 06:00:03 UTC
README
This custom fields add thumbnail ability to standard Image Field in Laravel Nova.
Take a look at this example:
NovaImageWithThumbs::make('Image', 'image') ->thumbs([ ['name' => 'thumbnail', 'w' => 200, 'h' => 100, 'method' => 'fit'], ]) ->disk('public') ->path('images-from-nova') ->prunable() ->hideFromIndex(),
This field will automatically generate two images on your disk and will fill image
and thumbnail
attribute of your model with path of these files.
Using $model->image
you will find original uploaded image and with $model->thumbnail
you will find a 200x100 image.
Configuration
thumbs
method accepts a list of associatable-array with these keys:
Prunable
NovaImageWithThumbs takes care of prunable images. If you delete a model with thumbnails, the field will automatically deletes useless files for you.
Show thumbnails to users
If you need to show thumbnails inside index or detail page, you can add a new standard Image Field to your resource:
Image::make('Thumbnail', 'thumbnail') ->disk('public') ->path('images-from-nova') ->exceptOnForms()