views:

28

answers:

1

Hi, i want to echo an Image inside an Zend Framework View Script (files cant be read by user)

This works in Controller:

        $service = My_Service_Factory::getFileServer();
        header('Content-Type: image/jpeg');
        echo $service->getProfilePicture($user); // returns binary string
        exit;

But how to implement this for Zend View?

A: 

Also not sure why you'd want this in a view...

It makes the most sense to get the response object, and change the content type there, as well as set the body.

$this->getResponse()->setHeader('Content-Type', 'image/jpeg')
                    ->setBody($service->getProfilePicture($user))
                    ->sendResponse();
Adrian Schneider