PHP code example of renepardon / croppa

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

    

renepardon / croppa example snippets


php artisan vendor:publish --tag=croppa

return [
	'src_dir' => public_path().'/uploads',
	'crops_dir' => public_path().'/uploads',
	'path' => 'uploads/(.*)$',
];

return [
	'src_dir' => '/www/public/images',
	'crops_dir' => '/www/public/images/crops',
	'path' => 'images/(?:crops/)?(.*)$',
	'url_prefix' => '/images/crops/',
];

// Early in App bootstrapping, bind a Flysystem instance.  This example assumes
// you are using the `graham-campbell/flysystem` Laravel adapter package
// https://github.com/GrahamCampbell/Laravel-Flysystem
App::singleton('s3', function($app) {
	return $app['flysystem']->connection();
});

// Or alternatively, without the Laravel-Flysystem package
App::singleton('s3', function () {
    return Storage::disk('s3')->getDriver();
});

// Croppa config.php
return [
	'src_dir' => 's3',
	'crops_dir' => public_path().'/uploads',
	'path' => 'uploads/(.*)$',
];

<img src="<?=Croppa::url($url, $width, $height, $options)

Croppa::render('/uploads/image-300x200.png');

Croppa::render(Croppa::url('/uploads/image.png', 300, 200));

Croppa::delete('/path/to/src.png');

Croppa::reset('/path/to/src.png');
error_page 404 = /index.php?$query_string;
nginx
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
  error_page 404 = /index.php?$query_string;
  expires 1M;
  access_log off;
  add_header Cache-Control "public";
}