Author: Carson Full (carsonfull@gmail.com)
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     if (!isset($app['thumbnails'])) {
         $app->register(new Thumbs\ServiceProvider());
     }
     $app['thumbnails.filesystems'] = ['files', 'themes'];
     $app['thumbnails.save_files'] = $app['config']->get('general/thumbnails/save_files');
     $app['thumbnails.filesystem_cache'] = $app->share(function ($app) {
         if ($app['thumbnails.save_files'] === false) {
             return null;
         }
         if (!$app['filesystem']->hasFilesystem('web')) {
             return null;
         }
         return $app['filesystem']->getFilesystem('web');
     });
     $app['thumbnails.caching'] = $app['config']->get('general/caching/thumbnails');
     $app['thumbnails.cache'] = $app->share(function ($app) {
         if ($app['thumbnails.caching'] === false) {
             return null;
         }
         return $app['cache'];
     });
     $app['thumbnails.default_image'] = $app->share(function ($app) {
         $matcher = new Matcher($app['filesystem'], ['view', 'app', 'themes', 'files']);
         try {
             return $matcher->getImage($app['config']->get('general/thumbnails/notfound_image'));
         } catch (FileNotFoundException $e) {
             return new Image();
         }
     });
     $app['thumbnails.error_image'] = $app->share(function ($app) {
         $matcher = new Matcher($app['filesystem'], ['view', 'app', 'themes', 'files']);
         try {
             return $matcher->getImage($app['config']->get('general/thumbnails/error_image'));
         } catch (FileNotFoundException $e) {
             return new Image();
         }
     });
     $app['thumbnails.default_imagesize'] = $app['config']->get('general/thumbnails/default_image');
     $app['thumbnails.cache_time'] = $app['config']->get('general/thumbnails/browser_cache_time');
     $app['thumbnails.limit_upscaling'] = !$app['config']->get('general/thumbnails/allow_upscale', false);
     $app['thumbnails.only_aliases'] = $app['config']->get('general/thumbnails/only_aliases', false);
     $app['thumbnails.aliases'] = $app['config']->get('theme/thumbnails/aliases', []);
     ImageResource::setNormalizeJpegOrientation($app['config']->get('general/thumbnails/exif_orientation', true));
     ImageResource::setQuality($app['config']->get('general/thumbnails/quality', 80));
 }
Exemplo n.º 2
0
Arquivo: Stack.php Projeto: bolt/bolt
 /**
  * Converts a list of paths to file objects.
  *
  * @param string[] $paths
  *
  * @return FileInterface[]
  */
 private function hydrateList($paths)
 {
     $files = array_filter(array_map(function ($path) {
         try {
             return $this->matcher->getFile($path);
         } catch (FileNotFoundException $e) {
             // Guess it doesn't exist anymore or we can't find it, remove from list.
             return null;
         }
     }, $paths));
     $files = array_slice($files, 0, self::MAX_ITEMS);
     return $files;
 }