You are here

function juicebox_field_display_alter in Juicebox HTML5 Responsive Image Galleries 7.2

Implements hook_field_display_alter().

Unlike most hook implementations in this file this one is "global" (it's not invoked only for this formatter).

File

includes/juicebox.field.inc, line 17
Contains all hooks and related methods for the juicebox_formatter field formatter.

Code

function juicebox_field_display_alter(&$display, $context) {

  // If this display is related to a Juicebox formatter we add some additional
  // metadata that the formatter can use. Most notably we add the actual
  // view mode name that this display relates to. Normally formatters don't need
  // to know this contextual info (and should not change their behavior based
  // on anything other than the raw configured display settings), but the
  // Juicebox case is unique.
  if (isset($display['type']) && $display['type'] == 'juicebox_formatter') {
    $display['juicebox_vm'] = $context['view_mode'];

    // Also, if this is a search-related display we need to flag the fact that
    // it's incompatible with the Juicebox javascript. Adding the Juicebox
    // javascript to a search result output will lead to errors. See issue
    // #2217791. Other incompatible view modes could be added here if needed.
    if ($context['view_mode'] == 'search_result' || $context['view_mode'] == 'search_index') {
      $display['juicebox_vm_incompatible'] = TRUE;
    }
  }
}