Package Data | |
---|---|
Maintainer Username: | 64robots |
Package Create Date: | 2018-08-31 |
Package Last Update: | 2023-03-04 |
Home Page: | |
Language: | Vue |
License: | MIT |
Last Refreshed: | 2024-11-17 03:06:26 |
Package Statistics | |
---|---|
Total Downloads: | 254,600 |
Monthly Downloads: | 2,216 |
Daily Downloads: | 21 |
Total Stars: | 57 |
Total Watchers: | 2 |
Total Forks: | 16 |
Total Open Issues: | 20 |
This field extends Image Field adding a handy cropper to manipulate images. Can be configurable in the same way as a File field in Nova.
Run this command into your nova project:
composer require r64/nova-image-cropper
use R64\NovaImageCropper\ImageCropper;
ImageCropper::make('Photo'),
In order to edit the existing image saved in the model, ImageCroper uses the preview method to return a base64 encoded image. You can either use the default implementation or override it as long as you return a base64 image.
use R64\NovaImageCropper\ImageCropper;
ImageCropper::make('Photo')
->preview(function () {
if (!$this->value) return null;
$url = Storage::disk($this->disk)->url($this->value);
$filetype = pathinfo($url)['extension'];
return 'data:image/' . $filetype . ';base64,' . base64_encode(file_get_contents($url));
});
You can add a rounded mask to the preview and the cropper
ImageCropper::make('Photo')->avatar()
Define the fixed aspect ratio of the crop box.
ImageCropper::make('Photo')->aspectRatio(16/9)
For free ratio use:
ImageCropper::make('Photo')->aspectRatio(0)
Set your translations in the corresponding xx.json file located in /resources/lang/vendor/nova
...
"Edit Image": "Editar Imagen",
"Cancel Crop": "Cancelar Recorte",
"Change Image": "Cambiar Imagen",
"Done": "Hecho",
"Click here or drop the file to upload": "Click aquí o arrastra el archivo para comenzar la subida"