lokesh / lightbox2

THE original Lightbox script (v2).
http://lokeshdhakar.com/projects/lightbox2/
MIT License
6.22k stars 1.77k forks source link

Some SVGs display as 0x0 image #552

Closed Pilchard123 closed 5 years ago

Pilchard123 commented 7 years ago

Some SVG files will open fine in a lightbox; others will collapse to a 0x0 image. I'm not sure what it is that makes the difference, but it may be related to viewbox or height/width attributes in the SVG itself. The behaviour does not seem to be consistent across browsers. In the example below, Firefox 49 and IE11 will collapse the left image, IE collapses both, and Chrome 53 and 54 work fine. I have not tested in other browsers.

Lightbox version: 2.9.0 Reproduced in:

To reproduce:

  1. Create a lightbox-enabled link to an SVG image (I think there is a particular quality of the image that matters, but I don't know what it is)
  2. Click the link to open the lightbox

Example: https://jsfiddle.net/Lj7cfnkL/9/ . The left-hand image is SVG and does not work as expected. The centre image is SVG and does work as expected. The right-hand image is PNG.

achaios commented 6 years ago

Here's a patch that fixes it. This is against 2.10.0 source, but I have only tested it on 2.9.0. The culprit is that some svgs report 0x0 size, so we just display them with maximum size. lightbox-fix-for-0-size-svgs.zip Github doesn't allow attaching *.patch files? How strange.

lokesh commented 5 years ago

https://github.com/lokesh/lightbox2/commit/9ea5e60c00ee334b5d8971ab3e00ba480406775e

lokesh commented 5 years ago

Fixed in v2.11.0: https://github.com/lokesh/lightbox2/releases/tag/v2.11.0