Tuesday, March 6, 2012

Re: Displaying images using MediaView based Controller - Help!

On Tue, Mar 6, 2012 at 4:32 PM, Blues Clues <bluesclues9@gmail.com> wrote:
> Can you elaborate on base64 encode comment? I thought the binary data is
> already needed to be encoded. do you have examples of doing this?

You need to base64_encode() the binary data. MediaView reads the
binary in buffered stages and simply echoes it out. There's no base64
functionality. Take a look at its _sendFile() method.

Here's a pretty good overview of what's required on the server side:

http://jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images

Keep in mind that base64-encoded images are a fair bit larger than
binary. Unless these are very small images, this might not be a good
idea. I think a better approach would be to skip MediaView and create
a view for this action which consists of just an img tag with
variables for the src, width, and height (which you'd set() in the
controller). Then also create an ajax.ctp layout which has just echo
$content_for_layout;

Also, there's no need such thing as '</img>'. Close the tag with ' />'.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate