PHP code example of insitaction / easycrop

1. Go to this page and download the library: Download insitaction/easycrop 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/ */

    

insitaction / easycrop example snippets


#bundles.php

return [
    Insitaction\EasyCropBundle\EasyCropBundle::class => ['all' => true],
    Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
];

    public function configureCrud(): Crud
    {
        return parent::configureCrud()
            ->addFormTheme('@EasyCrop/form_theme.html.twig')
            ;
    }


use Insitaction\EasyCropBundle\Field\CropField;

// ...

yield CropField::new('image', 'Image')
    ->setBasePath('/uploads/images/')
    ->setUploadDir('public/uploads/images/')
    ->setFormat('WEBP') // choices are 'PNG', 'JPEG', 'WEBP'.
    ->enableSizeValidation(true) // enable min size validation
    ->enableResize(true) // enable resize
    ->setHeight(600) // Set the desired height for resizing or validation
    ->setWidth(800)  // Set the desired width for resizing or validation
;