/** * @Route("/image/show/{id}", name="image_show") */ public function showImageAction(Image $image = null) { if ($image) { $response = new BinaryFileResponse($image->getAbsolutePath()); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $image->getName()); return $response; } else { throw new NotFoundHttpException(); } }