Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with query string images for video detection upgrade. (fix included) #97

Open
HawkenKing opened this issue Oct 20, 2024 · 0 comments

Comments

@HawkenKing
Copy link

HawkenKing commented Oct 20, 2024

If you are detecting images or videos and an image is loaded with a query string, for example in wordpress with a plugin, the lightbox can default to a video iframe if your code is augmented to run videos.

Here is a fix to keep images from turning into iframes when they have a query string url:

SlickLightbox.prototype.detectImage = function(url) {
    // Remove query string 
    url = url.split('?')[0];

    // Returns true if it finds an image file extension
    return url.match(/\.(jpeg|jpg|gif|png|webp)$/i) !== null;
};

Also added support for webp.

@HawkenKing HawkenKing changed the title compatibility with query string images. (fix included) compatibility with query string images for video detection upgrade. (fix included) Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant