Skip to content
This repository has been archived by the owner on Apr 15, 2021. It is now read-only.

External Images from API services not loading #60

Open
lithiumlab opened this issue Apr 2, 2016 · 0 comments
Open

External Images from API services not loading #60

lithiumlab opened this issue Apr 2, 2016 · 0 comments

Comments

@lithiumlab
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant