You are here

public function ElevateZoomPlusManager::getOptions in ElevateZoom Plus 7

Same name and namespace in other branches
  1. 8 src/ElevateZoomPlusManager.php \Drupal\elevatezoomplus\ElevateZoomPlusManager::getOptions()

Return the options for the JSON object.

File

src/ElevateZoomPlusManager.php, line 133

Class

ElevateZoomPlusManager
Provides ElevateZoom Plus library methods mainly for hooks.

Namespace

Drupal\elevatezoomplus

Code

public function getOptions(array $settings = []) {
  $plugin_id = isset($settings['plugin_id']) ? $settings['plugin_id'] : '';
  $option_id = $plugin_id == 'blazy_filter' ? $this->manager
    ->config('extras.elevatezoomplus', 'default') : $settings['elevatezoomplus'];
  $optionset = ElevateZoomPlus::load($option_id);
  $options = $optionset
    ->getSettings(TRUE);

  // If not using Slick Carousel, provides a static grid gallery.
  if (empty($settings['nav'])) {
    $options['galleryItem'] = '[data-elevatezoomplus-trigger]';
    $options['galleryActiveClass'] = 'is-active';
    if (isset($settings['gallery_id'])) {
      $options['gallery'] = $settings['gallery_id'];
    }
    else {
      $options['gallerySelector'] = '[data-elevatezoomplus-gallery]';
    }
  }
  if (isset($options['zoomWindowPosition']) && is_numeric($options['zoomWindowPosition'])) {
    $options['zoomWindowPosition'] = (int) $options['zoomWindowPosition'];
  }
  if (empty($options['loadingIcon'])) {
    unset($options['loadingIcon']);
  }
  return $options;
}