Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The image [...] cannot be displayed because it contains an error #67

Closed
DavidOliver opened this issue Jul 8, 2013 · 7 comments
Closed

Comments

@DavidOliver
Copy link
Member

ob_clean() was added to the renderOutputHeaders method a while back because @jonmifsud was getting images that browsers weren't recognising as valid.

This addition didn't pose any problem for me until now. I've set up a new dev environment using PHP 5.4, and I'm finding that the addition of ob_clean results in the same error @jonmifsud had without it.

Both of the following fix it for me:

  • Removing ob_clean()
  • Replacing ob_clean() with ob_end_clean()

Hopefully @jonmifsud will find that ob_end_clean() works, too. Having said that, if Symphony/JIT hasn't already added any output to the output buffer, neither of the ob_ calls should be necessary, right?

A comment from the ob_clean PHP page:

Don't use ob_clean() to clear white-space or other unwanted content "accidentally" generated by included files.
Included files should not generate unwanted content in the first place.
If they do, You are doing something wrong, like inserting white-space after "?>" (there should not be a "?>" at the end of PHP files: http://php.net/manual/en/language.basic-syntax.phptags.php ).

@brendo
Copy link
Member

brendo commented Jul 8, 2013

So, we need to track down whatever warning is being generated and sent
along with the image.

If you turn error reporting on to E_ALL in the image.php file, and then
set Display Errors 1 in your htaccess something ugly should up.

If not, try commenting out the line that outputs the image data so we've
just got a warning message.

@DavidOliver
Copy link
Member Author

I've changed lines 3 and 4 of image.php to:

@ini_set('display_errors', 'on');
@ini_set("gd.jpeg_ignore_warning", 0);

PHP is also set to E_ALL.

But I haven't managed to get any warnings or errors in my webserver's error log, Symphony's log or in the browser.

I've also tried commenting out a couple of lines which I think are responsible for outputting the image data:

// Display the image in the browser using the Quality setting from Symphony's
// Configuration. If this fails, trigger an error.
//if(!$image->display(intval($settings['image']['quality']))) {
    Page::renderStatusCode(Page::HTTP_STATUS_NOT_FOUND);
    trigger_error('Error generating image', E_USER_ERROR);
    echo 'Error generating image';
    exit;
//}

Anything else I can do to expose a warning?

Without ob_clean:

With ob_clean:

(The text is alt text of the broken image.)

@DavidOliver
Copy link
Member Author

Forgot to say that JIT's cache file is displayed successfully in Firefox if I open up the file directly from disk.

@jonmifsud
Copy link
Member

@DavidOliver in my new server environment we don't quite have the issue; there's a feeling that there was a whitespace in a config we had no access to previously (which we obviously couldn't figure out)

We've temporarily had an issue on the new setup; but it was also effecting other things; and had it resolved by the admin guys. If it works without ob_clean() I guess it should be fine to remove it. Though I'd add in the docs that whitespace in configs etc could lead to images not rendering (& reference both issues). Would save that person quite a lot of time debugging...

@DavidOliver
Copy link
Member Author

@jonmifsud, thanks. Are you able to confirm that JIT images do work without ob_clean? What version of PHP were/are you using?

@DavidOliver
Copy link
Member Author

Another user is getting this or a similar problem.

Are we okay to remove ob_clean()?

DavidOliver added a commit to DavidOliver/jit_image_manipulation that referenced this issue Jan 29, 2014
It was unnecessary and was causing errors in images in some environments. Sorts symphonycms#67
brendo added a commit that referenced this issue Feb 9, 2014
Remove ‘ob_clean’ function from renderOutputHeaders method. Fixes #67
@DavidOliver
Copy link
Member Author

Thanks for accepting the PR. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants