Source of file KrakenGDBackend.php
Size: 1,098 Bytes - Last Modified: 2021-12-23T10:19:23+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/KrakenGDBackend.php
123456789101112131415161718192021222324252627282930313233343536373839 | <?php /** * after writing file, optimizes the image using * the Kraken service * * @author Ryan */ class KrakenGDBackend extends GDBackend { /** * Calls the original writeTo function and then optimizes the image * @param String $filename */ public function writeTo($filename) { parent::writeTo($filename); $siteConfig = SiteConfig::current_site_config(); if(!$siteConfig->DisableKraken){ $krakenService = new KrakenService(); $data = $krakenService->optimizeImage($filename); //check if optimization was success if ($data['success'] && $data['saved_bytes'] >= 0) { //attempt to download the kraked file $krakedFile = $krakenService->getOptimizedImage($data['kraked_url']); //update the file if ($krakedFile) { file_put_contents($filename, $krakedFile); } } } } } |