简体   繁体   English

Drupal 8 - 第一页加载时不显示图像样式

[英]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. 我已尝试使用和不使用itok变量,结果相同。

  • 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'. 在第一页加载时,正在创建图像样式,我可以在样式文件夹中看到它,它在Windows中打开很好,但如果我查看图像样式URL(... / styles / stylename / public / folder / image .jpg)有一条消息说'图像无法显示,因为它包含错误'。 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. 它似乎是浏览器第一次尝试从缓存加载图像并且它不存在,因此URL被破坏。

Would love to hear if anyone else has encountered this issue. 如果有其他人遇到过这个问题,我很乐意听到。 Have tried everything I can think of. 尝试过我能想到的一切。

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. 这意味着在PHP代码中的某个位置,您会在标记之前出现意外的新行。 If this is only happening on one site then template.php in your theme is a good place to start looking. 如果这只发生在一个站点上,那么主题中的template.php是一个开始寻找的好地方。 refer this https://www.drupal.org/node/2195311 请参阅此https://www.drupal.org/node/2195311

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM