commit 689319776c979b2f2b74874a9d90a11ff8137f1f
parent 20076aa38fc9732463dd921853e6f0d32ad25df0
Author: Felicitus <felicitus@felicitus.org>
Date: Fri, 24 Jul 2015 19:18:16 +0200
Respect the passed width and height for the error messages
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/PartKeepr/ImageBundle/Controller/ImageController.php b/src/PartKeepr/ImageBundle/Controller/ImageController.php
@@ -43,10 +43,6 @@ abstract class ImageController extends FileController
*/
$image = $em->find($this->getEntityClass(), $id);
- if ($image === null) {
- return new ImageNotFoundResponse($request->get("width"), $request->get("height"));
- }
-
$width = $request->get("maxWidth");
$height = $request->get("maxHeight");
@@ -58,14 +54,17 @@ abstract class ImageController extends FileController
$height = 200;
}
+ if ($image === null) {
+ return new ImageNotFoundResponse($width, $height);
+ }
+
try {
$file = $this->fitWithin($image, $width, $height);
} catch (InvalidArgumentException $e) {
$this->get('logger')->error($e->getMessage());
- return new ImageNotFoundResponse($request->get("width"), $request->get("height"));
+ return new ImageNotFoundResponse($width, $height);
}
-
return new Response(file_get_contents($file), 200, array("Content-Type" => "image/png"));
}