Lightbox displays garbage characters instead of image

家住魔仙堡 提交于 2019-12-08 08:18:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!