/
ImageController.php
32 lines (28 loc) · 984 Bytes
/
ImageController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
class ImageController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
}
public function displayAction()
{
$boobs = $this->_getParam('boobs', null);
$kittens = $this->_getParam('kittens', null);
$mogileKey = null;
if ($boobs !== null) {
$mogileKey = Model_Images::TYPE_BOOBS . '-' . $boobs;
} else if ($kittens !== null) {
$mogileKey = Model_Images::TYPE_KITTENS . '-' . $kittens;
}
if ($mogileKey == null) {
throw new Exception('Invalid request');
}
$model = new Model_Images();
$image = $model->getImage($mogileKey);
$this->getResponse()->setHeader('Content-Type', 'image/jpeg');
$this->getResponse()->setHeader('Content-Length', strlen($image));
$this->getResponse()->setBody($image);
}
}