1. Go to this page and download the library: Download tobse/cakephp-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/ */
tobse / cakephp-image-cropper example snippets
public function bootstrap(): void
{
parent::bootstrap();
$this->addPlugin('ImageCropper');
}
public function initialize(): void
{
parent::initialize();
$this->loadHelper('Form', ['className' => 'ImageCropper.Cropper']);
$this->loadHelper('Html'); //
public function initialize(): void
{
parent::initialize();
$this->loadComponent('ImageCropper.SaveImage');
}
public function add()
{
$entity = $this->Articles->newEmptyEntity();
if ($this->request->is('post')) {
$this->SaveImage->process('image');
$entity = $this->Articles->patchEntity($entity, $this->request->getData());
if ($this->Articles->save($entity)) {
// handle the (now cropped) uploaded file as usual
}
}
$this->set(compact('entity'));
}