Beispiel #1
0
 public function route($url = null, $context = null)
 {
     $thumbs_path = fx::path()->http('@thumbs');
     $thumbs_path_trimmed = fx::path()->removeBase($thumbs_path);
     if (substr($url, 0, strlen($thumbs_path_trimmed)) !== $thumbs_path_trimmed) {
         return null;
     }
     $dir = substr($url, strlen($thumbs_path_trimmed));
     preg_match("~/([^/]+)(/.+\$)~", $dir, $parts);
     $config = $parts[1];
     $source_path = $parts[2];
     $source_abs = fx::path($source_path);
     if (!file_exists($source_abs)) {
         return null;
     }
     $target_dir = dirname(fx::path('@home/' . $url));
     if (!file_exists($target_dir) || !is_dir($target_dir)) {
         return null;
     }
     $config = $config . '.async-false.output-true';
     $config = \Floxim\Floxim\System\Thumb::readConfigFromPathString($config);
     fx::image($source_path, $config);
     fx::complete();
     die;
 }
Beispiel #2
0
 protected function handleThumbs()
 {
     fx::listen('unlink', function ($e) {
         $f = $e['file'];
         if (fx::files()->isMetaFile($f)) {
             return;
         }
         if (fx::path()->isInside($f, fx::path('@thumbs'))) {
             return;
         }
         if (!fx::path()->isInside($f, fx::path('@content_files'))) {
             return;
         }
         $thumbs = \Floxim\Floxim\System\Thumb::findThumbs($f);
         foreach ($thumbs as $thumb) {
             fx::files()->rm($thumb);
         }
     });
 }
Beispiel #3
0
 public static function image($value, $format)
 {
     try {
         $thumber = new Thumb($value, $format);
         $res = $thumber->getResultPath();
     } catch (\Exception $e) {
         fx::log('img exception', $e->getMessage());
         $res = '';
     }
     return $res;
 }