PHP code example of ultrasimplified / nova5-image-cropper
1. Go to this page and download the library: Download ultrasimplified/nova5-image-cropper 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/ */
ultrasimplified / nova5-image-cropper example snippets
namespace App\Nova;
// ...
use Ultrasimplified\ImageCropper\ImageCropper;
class Post extends Resource
{
// ...
public function fields(Request $request)
{
return [
// ...
// Simple image upload
ImageCropper::make('photo'),
// Show a cropbox with a free ratio
ImageCropper::make('photo')
->croppable(),
// Show a cropbox with a fixed ratio
ImageCropper::make('photo')
->croppable(16/9),
// Resize the image to a max width
ImageCropper::make('photo')
->resize(1920),
// Resize the image to a max height
ImageCropper::make('photo')
->resize(null, 1080),
// Show a cropbox and resize the image
ImageCropper::make('photo')
->croppable()
->resize(400, 300),
// Override the image processing driver for this field only
ImageCropper::make('photo')->driver('imagick')->croppable(),
// Convert the file to a different format
ImageCropper::make('photo')
->convert('webp')
// Store to AWS S3
AdvancedImage::make('photo')
->disk('s3'),
// Specify a custom subdirectory
ImageCropper::make('photo')
->disk('s3')
->path('image'),
];
}
}