PHP code example of bkwld / croppa
1. Go to this page and download the library: Download bkwld/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/ */
bkwld / croppa example snippets
php artisan vendor:publish --tag=croppa-config
return [
'src_disk' => 'public',
'crops_disk' => 'public',
'path' => 'storage/(.*)$',
];
// Croppa config.php
return [
'src_disk' => 's3',
'tmp_disk' => 'temp',
'crops_disk' => 'public',
'path' => 'storage/(.*)$',
];
<img src="{{ Croppa::url($url, $width, $height, $options) }}" />
<!-- Examples (that would produce the URLs above) -->
<img src="{{ Croppa::url('storage/image.webp', 300, 200) }}" />
<img src="{{ Croppa::url('storage/image.webp', null, 200) }}" />
<img src="{{ Croppa::url('storage/image.webp', 300) }}" />
<img src="{{ Croppa::url('storage/image.webp', 300, 200, ['resize']) }}" />
<img src="{{ Croppa::url('storage/image.webp', 300, 200, ['pad']) }}" />
<img src="{{ Croppa::url('storage/image.webp', 300, 200, ['pad' => [45,168,147]]) }}" />
<img src="{{ Croppa::url('storage/image.webp', 300, 200, ['quadrant' => 'T']) }}" />
<!-- Or, if there were multiple arguments for the last example -->
<img src="{{ Croppa::url('/uploads/image.png', 300, 200, ['quadrant' => ['T']]) }}" />
Croppa::render('image-300x200.png');
Croppa::render(Croppa::url('image.png', 300, 200));
Croppa::delete('/path/to/src.png');
Croppa::reset('/path/to/src.png');
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";
}