PHP code example of volkmann-design-code / kirby-upload-images
1. Go to this page and download the library: Download volkmann-design-code/kirby-upload-images 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/ */
volkmann-design-code / kirby-upload-images example snippets
// site/config/config.php
return [
'volkmann-design-code.upload-images' => [
// false (default): only where a file blueprint says `uploadImages`;
// true: every image upload; or fn (Kirby\Cms\File $file): bool
'enabled' => false,
// the long edge in pixels; null keeps the size
'maxSize' => 2560,
'quality' => 85,
// extension => format; other images keep theirs
'convert' => ['heic' => 'jpg', 'heif' => 'jpg'],
// remove EXIF, XMP & co. from the image (Imagick keeps the colour profile)
'strip' => true,
// metadata => file field, written before stripping
'fields' => ['taken' => 'taken', 'camera' => 'camera'],
// null: Imagick when installed and its ImageMagick knows the formats, else GD; or 'imagick', 'gd'
'driver' => null,
],
];
use VolkmannDesignCode\UploadImages\UploadImages;
['filename' => $filename, 'metadata' => $meta] = UploadImages::prepare($path, 'IMG_0001.HEIC', [
'maxSize' => 2560,
]);
// $path now holds a JPEG; $filename is "IMG_0001.jpg"; $meta['taken'], $meta['lat'] …
yaml
# site/blueprints/files/gallery.yml
accept:
type: image
uploadImages:
maxSize: 4096
fields:
taken: date
location: place # "51.31295, 9.480119"
sh
php -r 'echo Imagick::getVersion()["versionString"], " · HEIC: ", implode(",", Imagick::queryFormats("HEI*")) ?: "none", PHP_EOL;'