Codeinwp / Nivo-Lightbox-jQuery

A simple, flexible, responsive, retina-ready jQuery lightbox plugin.
http://dev7studios.com/nivo-lightbox
MIT License
157 stars 87 forks source link

External Images from API services not loading #60

Open lithiumlab opened 8 years ago

lithiumlab commented 8 years ago

Hi just to let you know the following issue and a possible correction:

When loading external images from services like Instagram and using Nivo Lightbox to display some images with urls not ending in .jpg or .png or etc are not loading correctly in the ligthbox. I've modded the regex to allow for those cases:

Example url from instagram API: https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/12383353_1705428166401484_523509799_n.jpg?ig_cache_key=MTIxODExMjEwNTk0MjMzMjg3Mw%3D%3D.2

in the line: https://github.com/gilbitron/Nivo-Lightbox/blob/master/nivo-lightbox.js#L164

if (s.match(/\.(jpeg|jpg|gif|png)$/i)

Used instead:

if (s.match(/\.(jpeg|jpg|gif|png)(?=[?#])|(\.)(?:[\w]+)$/i)

Even with this mod there's some corner cases when images that doesn't have extensions will be left out too. like: https://socialmediasite.com/img/34jefsedf34

Other lightbox plugins uses an option called type to let the plugin know we are going to load images. Maybe is a good addition:

$(".fancybox").fancybox({
   "type": "image"
});

See here: http://stackoverflow.com/a/6582227/1891792 And here http://stackoverflow.com/a/13986775/1891792 for related info