PHP code example of sunnysideup / silverstripe-scaled-uploads
1. Go to this page and download the library: Download sunnysideup/silverstripe-scaled-uploads 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/ */
sunnysideup / silverstripe-scaled-uploads example snippets
use Sunnysideup\ScaledUploads\Api\Resizer;
use SilverStripe\Assets\Image;
$runner = Resizer::create()
->setMaxHeight(100)
->setMaxFileSizeInMb(0.6)
->setDryRun(true)
->setVerbose(true);
$imagesIds = Image::get()->sort(['ID' => 'DESC'])->columnUnique();
foreach ($imagesIds as $imageID) {
$image = Image::get()->byID($imageID);
if ($image->exists()) {
$runner->runFromDbFile($image);
}
}