When a page is loaded containing one or more lightgalleries a javascript is triggered:

Uncaught ReferenceError: id is not defined

This causes not initiating the lightgallery for the element.

The error is within the js/lightgallery_load.js file; the variable id is used before being declared.

      for (id in settings.lightgallery.instances) {
        // Store galleries so that developers can change options.
        that.galleries[id] = settings.lightgallery.instances[id];
        _lightgallery_init(id, that.galleries[id], context);
      }

Adding var before the id fixed the issue:

      for (var id in settings.lightgallery.instances) {
        // Store galleries so that developers can change options.
        that.galleries[id] = settings.lightgallery.instances[id];
        _lightgallery_init(id, that.galleries[id], context);
      }

Comments

zero2one created an issue. See original summary.

zero2one’s picture

Issue summary: View changes
zero2one’s picture

This patch fixes the issue.

mpp’s picture

Status: Active » Reviewed & tested by the community

Every var counts ;-)

mpp’s picture

StatusFileSize
new636 bytes

Or you could declare the var before the for structure but that's a matter of taste I assume.
Also fixed a missing newline.

mpp’s picture

StatusFileSize
new787 bytes

According to the javascript coding standards we should put the var in the for structure.
See https://www.drupal.org/docs/develop/standards/javascript/javascript-codi...

Updated patch with the missing newline.

phjou’s picture

The patch doesn't seem to apply anymore.

  • phjou committed c8049ce on 8.x-1.x
    Issue #3028083 by mpp, zero2one, phjou: Lightgallery not started due to...
phjou’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.