Maybe I'm missing something here, but why is Router:url even needed?
The only thing you needed to do was to switch the layout to one
appropriate for displaying binary data (e.g. a blank layout like ajax)
and set debug to 0 to suppress the SQL output. All of this could have
been done by the
Wow, that was not nearly as well-formatted as I had hoped. Hope it's
still comprehensible. In any case, the import parts are simply:
1. use Router::parseExtensions() to parse image extensions and pass
them to $RequestHandler (perhaps define the extensions array as a
model property to maintain
Thanks Calvin, I'm still working on it trying to overcome other issues. I've
discovered that manipulating dynamically generated images using blob as
the base (original) image is next to impossible unless I'm missing something
which is extremely likely considering I don't know beans about it
Well, that's just how I would do it. If the other way works, and it's
less work for you, then there's no need to change it. It's just
natural for me to use RequestHandler since on most sites I already
have it loaded for AJAX and RSS.
As to manipulating images with PHP... I've only minimal
Funny you mention imagecreatefromstring(), it's the only one that does work
(and so it should) with binary straight from the db.
imagecreatefromjpeg() - (png. etc.)
imagecreatetruecolor()
imagecopyresampled()
imagejpeg() - (png. etc.)
all have their own set of issues. I went through (what seems
I've been toying with this one for a while now and I'm not really getting
anywhere.
I'm trying to display a photo stored in db as type blob. With conventional
PHP I would normally store the photo with type binary and never had any
issues ... Blob is not going so well.
I figure the problem has
Besides the size there should be no diff between binary and blob, I was
just thinking that perhaps Cake handled them differently.
I played around with media view and it doesn't seem to be what I'm looking
for.
I have it narrowed down to the headers and I can get the photo to display
but it has to
An approach
in the controller:
function show_image($recordId) {
$this-set('data', $this-Model-findById($recordId));
$this-layout = 'ajax'
}
the view show_image.ctp:
Configure::write('debug', 0);
header(Content-type: image/jpeg); //assume jpg image
echo $data['Model']['blob_file'];
Thanks Martin, it worked just fine.
It turns out that with all I have tried I was actually close.
$this-layout = 'ajax'
AND
Router::url
made all the difference in the world.
I nearly fell out of my chair when the image displayed :)
- Ed
On Wed, May 12, 2010 at 11:54 PM, Martin Radosta