You are here

function lightgallery_add in Lightgallery 7

This function loads the required JavaScripts and css for a lightgallery instance.

Parameters

type $id:

type $option_set:

2 calls to lightgallery_add()
template_preprocess_lightgallery_view in ./lightgallery.module
Display a view as a Lightgallery style.
theme_lightgallery_image_formatter in includes/lightgallery.theme.inc
Returns HTML for an Lightgallery image field formatter.

File

./lightgallery.module, line 160

Code

function lightgallery_add($id = NULL, $option_set = NULL) {

  // Add library.
  if (!($library = libraries_load('lightgallery')) || empty($library['loaded'])) {
    drupal_set_message(t('Lightgallery library was not found.'), 'error');
    return FALSE;
  }

  // If the ID or optionset aren't set, it is assumed the settings will be set
  // manually via the calling module/theme
  if (!empty($id) && !empty($option_set)) {

    // JavaScript settings
    $js_settings = array(
      'instances' => array(
        $id => $option_set,
      ),
    );

    // Add settings.
    drupal_add_js(array(
      'lightgallery' => $js_settings,
    ), 'setting');

    // Add loader file.
    drupal_add_js(drupal_get_path('module', 'lightgallery') . '/js/lightgallery_load.js', array(
      'type' => 'file',
      'scope' => 'footer',
    ));
  }
}