views:

45

answers:

2

While serving images through CakePHP, I'm getting

The image "http://DOMAIN/PLUGIN/images/image.png" cannot be displayed, because it contains errors.

There is a bug report already existing, http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/864

As mentioned in the above bug report, whitespace is the culprit here. Can someone throw some light upon where exactly I have to look for these white spaces? I've checked at the end of all my files, there are no white spaces. So where else should I be checking for these white spaces?

Thanks in advance for your time.

A: 

The solution mentioned in the link is not ideal (adding ob_clean(); flush(); in dispatcher.php), but have you tried it?

If you just want to remove the whitespaces, make sure you have debugging turned on in config/core.php, and click on the link provided by the debugger when the error pops up. It will show you a stack trace (list of all the files that were used to load the current page), and you can review those files in your app folder to see if there are extra spaces before or after the php tags.

handsofaten
Yes, I tried it.. It worked in my local LAMP server. But when I uploaded it to my host, it didn't work.. It was outputting garbage values. So in effect, that solution didn't work.
Ashok
Even though debugging is turned on, when we access the images it is not showing any debug info (Accessing http://localhost/test/image/testing.jpg will show the error given in my first post).
Ashok
I see you found a solution... thanks for posting
handsofaten
thanks to you too for your time :)
Ashok
A: 

I've solved this problem by creating a symlink from my plugin webroot to app/webroot... Though not an ideal solution, this is more forgiving with accidental white spaces which are very difficult to find.

A side effect advantage to this solution is that according to http://book.cakephp.org/view/1093/Themes, serving plug-in assets directly from webroot is much faster than serving them through CakePHP's dispatcher.

Thanks everyone for your time.

Ashok