You are here

function lightbox2_field_formatter_info in Lightbox2 8

Same name and namespace in other branches
  1. 5.2 lightbox2.module \lightbox2_field_formatter_info()
  2. 5 lightbox2.module \lightbox2_field_formatter_info()
  3. 6 lightbox2.module \lightbox2_field_formatter_info()
  4. 7.2 lightbox2.module \lightbox2_field_formatter_info()
  5. 7 lightbox2.module \lightbox2_field_formatter_info()

Implementation of hook_field_formatter_info().

Add certain lightbox and imagecache formatters to CCK image fields if the imagefield.module and the imagecache.module exist. Add additional formatters if emfield, emimage and/or emvideo modules exist.

1 call to lightbox2_field_formatter_info()
lightbox2_insert_styles in ./lightbox2.insert.inc
Implementation of hook_insert_styles().

File

./lightbox2.module, line 990
Enables the use of lightbox2 which places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths.

Code

function lightbox2_field_formatter_info() {
  $formatters = array();
  if (\Drupal::moduleHandler()
    ->moduleExists('image')) {
    $formatters['lightbox2'] = array(
      'label' => 'Lightbox2',
      'field types' => array(
        'image',
      ),
      'settings' => array(
        'type' => 'lightbox',
        'image_style' => 'original',
        'lightbox_style' => 'original',
        'caption' => 'hidden',
      ),
    );
  }
  return $formatters;

  /*
  // Handle imagefield and filefield images.
  if (module_exists('image')) {
  	$rules = array();
    if (function_exists('image_styles')) {
      $presets = image_styles();
      foreach ($presets as $preset_id => $preset_info) {
        $rules[$preset_id] = $preset_info['name'];
      }
    }
    $iframe['image__lightframe2__original__node'] = array(
      'label' => 'Lightbox2 iframe: original->node page',
      'field types' => array('image', 'file'),
    );
    $iframe['imagefield__lightframe2__link__node'] = array(
      'label' => 'Lightbox2 iframe: link->node page',
      'field types' => array('image', 'file'),
    );
    foreach ($rules as $view_rule) {
      $lightbox['image__lightbox2__original__'. $view_rule] = array(
        'label' => 'Lightbox2: original->'. $view_rule,
        'field types' => array('image', 'file'),
      );
      $lightbox['imagefield__lightbox2_compact__original__'. $view_rule] = array(
        'label' => 'Lightbox2: original->'. $view_rule . ' compact',
        'field types' => array('image', 'file'),
      );
      $lightbox['image__lightbox2__'. $view_rule .'__original'] = array(
        'label' => 'Lightbox2: '. $view_rule .'->original',
        'field types' => array('image', 'file'),
      );
      $lightbox['imagefield__lightbox2_compact__'. $view_rule .'__original'] = array(
        'label' => 'Lightbox2: '. $view_rule .'->original compact',
        'field types' => array('image', 'file'),
      );
      $lightbox['imagefield__lightbox2__link__'. $view_rule] = array(
        'label' => 'Lightbox2: link->'. $view_rule,
        'field types' => array('image', 'file'),
      );
      $slideshow['image__lightshow2__original__'. $view_rule] = array(
        'label' => 'Lightbox2 slideshow: original->'. $view_rule,
        'field types' => array('image', 'file'),
      );
      $slideshow['imagefield__lightshow2_compact__original__'. $view_rule] = array(
        'label' => 'Lightbox2 slideshow: original->'. $view_rule . ' compact',
        'field types' => array('image', 'filefield'),
      );
      $slideshow['image__lightshow2__'. $view_rule .'__original'] = array(
        'label' => 'Lightbox2 slideshow: '. $view_rule .'->original',
        'field types' => array('image', 'file'),
      );
      $slideshow['imagefield__lightshow2_compact__'. $view_rule .'__original'] = array(
        'label' => 'Lightbox2 slideshow: '. $view_rule .'->original compact',
        'field types' => array('image', 'filefield'),
      );
      $slideshow['imagefield__lightshow2__link__'. $view_rule] = array(
        'label' => 'Lightbox2 slideshow: link->'. $view_rule,
        'field types' => array('image', 'filefield'),
      );
      $iframe['image__lightframe2__'. $view_rule .'__node'] = array(
        'label' => 'Lightbox2 iframe: '. $view_rule .'->node page',
        'field types' => array('image', 'file'),
      );
  	foreach ($rules as $lightbox_rule) {
        $lightbox['image__lightbox2__'. $view_rule .'__'. $lightbox_rule] = array(
  	 'label' => 'Lightbox2: '. $view_rule .'->'. $lightbox_rule,
          'field types' => array('image', 'file'),
        );
        $lightbox['imagefield__lightbox2_compact__'. $view_rule .'__'. $lightbox_rule] = array(
          'label' => 'Lightbox2: '. $view_rule .'->'. $lightbox_rule . ' compact',
          'field types' => array('image', 'filefield'),
        );
        $slideshow['image__lightshow2__'. $view_rule .'__'. $lightbox_rule] = array(
          'label' => 'Lightbox2 slideshow: '. $view_rule .'->'. $lightbox_rule,
          'field types' => array('image', 'file'),
        );
        $slideshow['imagefield__lightshow2_compact__'. $view_rule .'__'. $lightbox_rule] = array(
          'label' => 'Lightbox2 slideshow: '. $view_rule .'->'. $lightbox_rule . ' compact',
          'field types' => array('image', 'filefield'),
        );
      }
    }
    // Adding them now so they are in some sort of sensible order.
    $formatters = array_merge($lightbox, $slideshow, $iframe);
  }
  if (module_exists('emfield') && module_exists('emimage')) {
    $formatters['emimage_lightbox2'] = array(
      'label' => t('Lightbox2: Image Thumbnail -> Original'),
      'field types' => array('emimage'),
    );
    $formatters['emimage_lightshow2'] = array(
      'label' => t('Lightbox2 slideshow: Image Thumbnail -> Original'),
      'field types' => array('emimage'),
    );
    $formatters['emimage_lightframe2'] = array(
      'label' => t('Lightbox2 iframe: Image Thumbnail -> Content'),
      'field types' => array('emimage'),
    );
  }
  if (variable_get('lightbox2_enable_video', FALSE) && module_exists('emfield') && module_exists('emvideo')) {
    $formatters['emvideo_lightvideo'] = array(
      'label' => t('Lightbox2: Image Thumbnail -> Full Size Video'),
      'field types' => array('emvideo'),
    );
  }
  if (module_exists('file')) {
    $formatters['file_lightframe'] = array(
      'label' => t('Lightbox2 iframe'),
      'field types' => array('file'),
    );
  }
  */
}