0

Currently I have lightgallery which working perfectly, but when I import additional plugin to it "lg-zoom.js" I'm getting error "property 'modules' of undefined".

In the functions.php I have:

  wp_enqueue_script('lightgallery', get_template_directory_uri() . "/assets/vendor/lightgallery.min.js", array('jquery'), WEB_VERSION, false);
    wp_enqueue_script('lg-zoom', get_template_directory_uri() . "/assets/vendor/lg-zoom.min.js", array('jquery'), WEB_VERSION, false);

1 Answers1

1

Try adding the main lightgallery script as a dependency to the lg-zoom module:

wp_enqueue_script('lightgallery', get_template_directory_uri() . "/assets/vendor/lightgallery.min.js", array('jquery'), WEB_VERSION, false);
wp_enqueue_script('lg-zoom', get_template_directory_uri() . "/assets/vendor/lg-zoom.min.js", array('jquery', 'lightgallery'), WEB_VERSION, false); // 'jquery' could be even skipped here, since lightgallery already requires it. 
Zoli Szabó
  • 4,366
  • 1
  • 13
  • 19
  • Thanks for answer, but unfortunately still getting same error, should I try to use imports instead of functions.php? https://github.com/sachinchoolur/lightGallery/issues/749 – randomCoder Jun 01 '21 at 11:57
  • It seems that lightGallery v2+ is largely different from v1. It is not using jQuery anymore. What version of lightgallery are you including? https://github.com/sachinchoolur/lightGallery/tree/2.0.0 – Zoli Szabó Jun 01 '21 at 12:14
  • This one https://github.com/sachinchoolur/lightgallery.js – randomCoder Jun 01 '21 at 12:42
  • 1
    Please read https://github.com/sachinchoolur/lightgallery.js#important-notice. Also see the readme on including plugins: https://github.com/sachinchoolur/lightGallery/tree/2.0.0#include-css-and-javascript-files – Zoli Szabó Jun 01 '21 at 12:59