问题
I have installed a lightbox script in my website. When lightbox pops up, but there are garbage characters displaying instead of the large version of the image:
����JFIF��;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 ��C ��C ����"�� ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������
What is this? It looks like it's relevant to the image file but I don't understand what causes this issue... Any suggestions?
Edit: Here's the whole code of the image.
回答1:
in the php file where you are creating the image dynamically using GD liabrary write following code.
header("content-type:image/jpg");
OR if it is a png image then
header("content-type:image/png");
From the code it seems to be a jpg file. But you should know the format.
Basically it is problem in php file rather than the lightbox.
回答2:
Just had this after I was doing some random tasks. Couldn't see why images were displaying fine until I attempted to load them in lightbox, turns out the html attributes had non-displaying characters on the end of the filename.
<a href="image1.jpg"><img src="image1.jpg" /></a>
had become:
<a href="image1.jpg
"><img src="image1.jpg
" /></a>
Trimming the filenames (in my case with PHP's trim() function) to remove these erroneous characters made it behave correctly.
回答3:
You have to update the colorbox js file as the following:
photoRegex: /\.(gif|jfif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
来源:https://stackoverflow.com/questions/10683700/lightbox-displays-garbage-characters-instead-of-image