homelessDevOps
homelessDevOps

Reputation: 20726

Echo binary (image) in Zend View

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?

Upvotes: 0

Views: 419

Answers (1)

Adrian Schneider
Adrian Schneider

Reputation: 7449

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();

Upvotes: 1

Related Questions