You are here

function _juicebox_init_display_settings in Juicebox HTML5 Responsive Image Galleries 7

Utility function to modify Juicebox settings after they are loaded from Drupal but before they are used in any Juicebox module logic.

This is a central place to modify the $settings arrays that describe the configuration for each Juicebox gallery (for both field formatters and views displays). Note that for views we could implement an override of views_plugin_style::init and do these modifications there, but as no such option exists for field formatters we just use this ad hoc utilty for both instead.

Parameters

array $settings: An associative array containing all the settings for a Juicebox gallery.

Return value

array A modified version of the input settings array.

5 calls to _juicebox_init_display_settings()
juicebox_field_formatter_settings_form in ./juicebox.module
Implements hook_field_formatter_settings_form().
juicebox_field_formatter_view in ./juicebox.module
Implements hook_field_formatter_view().
juicebox_page_xml in ./juicebox.module
Menu callback: generate Juicebox XML.
juicebox_style_plugin::options_form in plugins/juicebox_style_plugin.inc
Define plugin options form.
juicebox_style_plugin::render in plugins/juicebox_style_plugin.inc
Render the view page display.

File

./juicebox.module, line 587
Provides Drupal integration with the Juicebox library.

Code

function _juicebox_init_display_settings($settings) {

  // Here we check for cases where we may be loading settings stored with an
  // older version of the module. In these cases the settings "schema" may be
  // different (i.e. the array is nested differently), so we need to adjust
  // accordingly. Note that this is done here "realtime" instead of via a
  // one-time hook_update_n process because this is the only way to correctly
  // deal with views and fields being loaded from code (exported). Once "old"
  // settings are re-saved (under the new "schema"), these checks no longer do
  // anything. See also: http://drupal.org/node/1965786
  if (!empty($settings['width'])) {
    $settings['jlib_galleryWidth'] = $settings['width'];
  }
  if (!empty($settings['height'])) {
    $settings['jlib_galleryHeight'] = $settings['height'];
  }
  if (!empty($settings['advanced']['config'])) {
    $settings['manual_config'] = $settings['advanced']['config'];
  }
  if (!empty($settings['advanced']['custom_parent_classes'])) {
    $settings['custom_parent_classes'] = $settings['advanced']['custom_parent_classes'];
  }
  if (!empty($settings['linkurl_field'])) {
    $settings['linkurl_source'] = $settings['linkurl_field'];
  }
  return $settings;
}