You are here

function juicebox_field_formatter_info in Juicebox HTML5 Responsive Image Galleries 7.2

Same name and namespace in other branches
  1. 7 juicebox.module \juicebox_field_formatter_info()

Implements hook_field_formatter_info().

Add juicebox_formatter formatter. Note that this hook is only fired on cache updates to set defaults.

File

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

Code

function juicebox_field_formatter_info() {

  // Get the base settings. This function may be called while clearing caches
  // so let's be extra careful about catching any errors gracefully.
  try {
    $juicebox = juicebox();
    $base_settings = $juicebox
      ->confBaseOptions();
    $library = $juicebox->library;
  } catch (Exception $e) {
    $message = 'Exception fetching base configuration options for Juicebox field formatter: !message in %function (line %line of %file).';
    watchdog_exception('juicebox', $e, $message);
    return array();
  }
  $formatters = array(
    'juicebox_formatter' => array(
      'label' => t('Juicebox Gallery'),
      'description' => t('Style groups of images or files as a Juicebox gallery.'),
      'field types' => array(
        'image',
        'file',
      ),
      'settings' => array_merge($base_settings, array(
        // If the library supports multi-size we can default to that for the
        // main image, otherwise use the "medium" style.
        'image_style' => !empty($library['version']) && !in_array('juicebox_multisize_image_style', $library['disallowed_conf']) ? 'juicebox_multisize' : 'juicebox_medium',
        'thumb_style' => 'juicebox_square_thumbnail',
        'caption_source' => '',
        'title_source' => '',
      )),
    ),
  );
  return $formatters;
}