I have images of a certain image style that only show up after reloading the page. I can see the image created in the style directory after the first page request. Its like the browser is not waiting for the image to be created.

I wrote a curl script to request all the images of that style on the site, which works. But I'm worried that when new images are added they won't show on first request. Any idea what would cause that?


I spent most of the day yesterday working on this. It happens when the derivative image is first created and served by Drupal. I found an extra new line character at the beginning of the image. If I save it to my desktop and remove the newline it works fine.

I read elsewhere that this can be caused by an extra space in a file like settings.php or template.php, usually before the <?php or after the ?> if it has one. I checked and rechecked those files and I've also been using find and grep to try and find the offending file but so far no luck.

I also tried adding header("Fake: fake"); to different files to see if I could generate a "headers already sent" error. But the output buffering Drupal uses seems to prevent that from working. Also I added $conf['image_allow_insecure_derivatives'] = TRUE;` to settings.php but that didn't fix it either.

2 Answers 2


There was extra space before the <?php in index.php. Not sure how I missed it with all my searching before.


I had a similar issue but it was a database setting that was causing this. If my page had multiple images, it would load one image style per load.

To fix this I updated /usr/local/mysql/my.cnf and set:

max_allowed_packet = 128M

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.