Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Improve trigger on images with a different a.href #199

Description

@egantz

Hi! First of all I would like to share my love to this library! keep up the great work.

I was just implementing it in one of my projects and I bumped in an interesting case - When I use jQuery to call fluidbox() on all of the 'a' in the DOM.

I have 2 images:

  1. Links to itself, so the a element links to the JPG file, and the child img element links to the same JPG file.
  2. Links to a different location, so the a links to a website, and the child img element links to the JPG file.

What happens that image #2 breaks because the library doesn't check if both URLs are equal and only then triggers the fluidbox()

I have written a tiny workaround but maybe it will be possible to have an official solution for that?

$('a').each(function() {
      const href = $(this).attr('href');
      if (href) {
        const imgSrc = $(this).find('img').attr('src');
        if (imgSrc) {
          if (href === imgSrc) {
            $(this).fluidbox();
          }
        }
      }
    });

instead of just:

$('a').fluidbox();

Many thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions