I am facing a strange issue regarding image preview in Drupal 8. I am not sure in which category, I need to post this issue. I tried will all the patches available in the net
-disable "itok"
-set permission 775 to sites/default/files/styles directory and subdirectory
-even changed the default file permission from 0664 to 0775
-disable Options in .htaccess file
None is working
The image below is a preview page by "focal point" module. You see the preview is not showing. But if i click on preview, the image is showing at the bottom. I checked in the corresponding folder all preview images are there. A sample url is like this:
`/sites/default/files/styles/facebook/public/assets/Q292ZXIyMDExLTA2LTIzIDE5OjE2OjI3.jpg`
Now if I go directly to that image in browser, its displaying correctly. And after that, if I refresh the focal point preview, now that image will display. But if I clear the varnish cache, everything will be as before.
In whole site, where there is image preview, after upload or any preview, its happening the same.
The system is based on Drupal 8.4.x
- Its in Acquia Hosting
- Its using Media Entity, Media Entity Image, Entity Browser, Crop modules etc
I am banging my head almost two days, no clue of this issue. If anyone can help, will be highly appreciated!!
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Screenshot from 2024-04-22 08-23-42.png | 95.52 KB | abuhozaifa |
| #3 | media-image-error2.png | 25.87 KB | shafiqhossain |
| media-image-error.png | 290.38 KB | shafiqhossain |
Comments
Comment #2
cilefen commentedWhat, if any, is the HTTP error code? This may be seen on the browser console.
Comment #3
shafiqhossain commentedNo error log to anywhere, not in console, not in watchdog, not in php error log. The image is there, but not loading / rendering.
Comment #4
cilefen commentedHave you checked the focal point module's issue queue? What is the theme?
Comment #5
shafiqhossain commentedThis is actually not focal point module issue. In the site, everywhere i see the same problem.
I have created a fresh new content type and added a image field with no link to any module (media, focal point, media entity image etc.), where preview is set to Thumbnail 100 x 100. Still the image preview is not showing after upload.
Strange thing is that, if i upload the same image twice - for first upload, its not showing the preview, but in the second upload, image preview is showing.
Comment #6
shafiqhossain commentedOkay after spent 2 days on this, I figure out the issue. Somebody added some debug code at the top of the settings.php file, which causes the image preview not working. Like this:
After removing those lines and the following blank lines, everything working fine.
Comment #7
shafiqhossain commentedComment #8
amanire commentedJust ran into a very similar issue, not just for the focal point image preview but for all image styles. It was caused by some whitespace before the
<?phptag. It apparently hadn't manifested until upgrading to Drupal 9. Amazingly, this issue thread helped us to narrow down the culprit. So many thanks to @shafiqhossain for posting the solution here and giving us a clue where to look!Update: oops, didn't mean to change the issue version to 10.0.x-dev, but I guess it's still relevant.
Comment #9
abuhozaifa commentedHi Team,
Whenever I add an image, it appears to be added but the thumbnail is shown as broken and when I right-click, it is shown again with a loaded image. I have already checked the permission.
Current Step:
1. Sudo chmod -R 0777 files
2. Sudo chmod -R 0777 files/styles
3. Sudo chmod -R 0777 web
Nothing is working! but the image is created and stored in the directory.
Thanks,