PHP code example of cita / image-cropper

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

    

cita / image-cropper example snippets


    ...
    use Cita\ImageCropper\Model\CitaCroppableImage;
    use Cita\ImageCropper\Fields\CroppableImageField;
    ...
    private static $has_one = array(
        'Photo'     =>  CitaCroppableImage::class
    );


    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        ...
        // adding a free cropper
        $fields->addFieldToTab(TAB_NAME, CroppableImageField::create('PhotoID', A_TITLE_TO_THE_FILED));

        // adding cropper with ratio
        $fields->addFieldToTab(TAB_NAME, CroppableImageField::create('PhotoID', A_TITLE_TO_THE_FILED)->setCropperRatio(16/9));
        ...
        return $fields;        
    }