Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal 8 - Image styles not displaying on first page load

I am using Entity Browser to upload images and Responsive Image Styles to display them.

I am finding that once a node is created and an image is added, the first time a new user visits the page, the image will not display. A refresh of the page will then show the image.

  • I have tried both with and without the itok variable, same result.

  • I have tried using a responsive image style and a normal image style and the same result.

  • When an image is first uploaded in the backend, the thumbnail doesnt show.

  • The image is uploading correctly and its in the files folder.

Upon the first page load, the image style is being created and I can see it in the styles folder and it opens fine in windows, but if I view the image styles URL (.../styles/stylename/public/folder/image.jpg) there is a message saying 'The image cannot be displayed because it contains errors'. If i do a hard fresh on that, the image shows up, then go back and refresh the page and the image is there.

Its seems like the browser is trying to load the image from cache first time around and it doesnt exists, so the url is broken.

Would love to hear if anyone else has encountered this issue. Have tried everything I can think of.

like image 318
LindsayWilsonOrigin Avatar asked Nov 19 '16 02:11

LindsayWilsonOrigin


1 Answers

The first character in your broken image file is a newline. If you remove the first byte the image can be successfully displayed。

This means that somewhere in your PHP code you have a unexpected new line, either before the tag. If this is only happening on one site then template.php in your theme is a good place to start looking. refer this https://www.drupal.org/node/2195311

like image 79
LF00 Avatar answered Nov 11 '22 22:11

LF00