$app->notFound(function () use($app) { $app->render('404.html.twig'); }); //custom error handler $app->error(function (\Exception $e) use($app, $conf, $app_base_url) { $resuUri = $app->request()->getResourceUri(); $etype = get_class($e); Analog::error('exception \'' . $etype . '\' with message \'' . $e->getMessage() . '\' in ' . $e->getFile() . ':' . $e->getLine() . "\nStack trace:\n" . $e->getTraceAsString()); if ((substr($resuUri, 0, 10) === '/ajax/img/' || substr($resuUri, 0, 21) === '/ajax/representative/') && APP_DEBUG !== true) { $format = 'default'; preg_match('/.*\\/format\\/(.*)/', $resuUri, $matches); if (isset($matches[1])) { $format = $matches[1]; } $picture = new Picture($conf, DEFAULT_PICTURE, $app_base_url); $display = $picture->getDisplay($format); $response = $app->response(); foreach ($display['headers'] as $key => $header) { $response[$key] = $header; } $response->body($display['content']); } else { $app->render('50x.html.twig', array('exception' => $e)); } }); //main route $app->get('/', function () use($app, $app_base_url) { $app->redirect($app_base_url . '/viewer/' . DEFAULT_PICTURE); }); //include routes files require_once 'routes/images.routes.php';
/** Test image inside a subdirectory * * @return void */ public function testSeriesImage() { $picture = new Viewer\Picture($this->_conf, $this->_series->getFullPath() . 'tech.jpg', null); $display = $picture->getDisplay('thumb'); $length = $display['headers']['Content-Length']; $this->integer($length)->isIdenticalTo(6827); }