You are here

function shadowbox_field_formatter_info in Shadowbox 5

Same name and namespace in other branches
  1. 5.2 shadowbox.module \shadowbox_field_formatter_info()
  2. 6.4 shadowbox.module \shadowbox_field_formatter_info()
  3. 6.2 shadowbox.module \shadowbox_field_formatter_info()
  4. 6.3 shadowbox.module \shadowbox_field_formatter_info()
  5. 7.3 shadowbox.module \shadowbox_field_formatter_info()

Implementation of hook_field_formatter_info().

Add certain shadowbox+imagecache formatters to CCK image fields if the imagefield.module and the imagecache.module exist.

File

./shadowbox.module, line 523
Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.

Code

function shadowbox_field_formatter_info() {
  $formatter = array();
  if (module_exists('imagefield') && module_exists('imagecache')) {
    $rules = array();
    if (function_exists('imagecache_presets')) {
      $presets = imagecache_presets();
      foreach ($presets as $preset_id => $preset_info) {
        $rules[$preset_id] = $preset_info['presetname'];
      }
    }
    else {
      $rules = _imagecache_get_presets();
    }
    foreach ($rules as $ruleid => $view_rule) {
      $formatters['shadowbox][original][' . $view_rule] = array(
        'label' => 'shadowbox: original to ' . $view_rule,
        'field types' => array(
          'image',
        ),
      );
      $formatters['shadowbox][' . $view_rule . '][original'] = array(
        'label' => 'shadowbox: ' . $view_rule . ' to original',
        'field types' => array(
          'image',
        ),
      );
      $formatters['shadowbox_gallery][original][' . $view_rule] = array(
        'label' => 'shadowbox gallery: original to ' . $view_rule,
        'field types' => array(
          'image',
        ),
      );
      $formatters['shadowbox_gallery][' . $view_rule . '][original'] = array(
        'label' => 'shadowbox gallery: ' . $view_rule . ' to original',
        'field types' => array(
          'image',
        ),
      );
      foreach ($rules as $rid => $shadowbox_rule) {
        $formatters['shadowbox][' . $view_rule . '][' . $shadowbox_rule] = array(
          'label' => 'shadowbox: ' . $view_rule . ' to ' . $shadowbox_rule,
          'field types' => array(
            'image',
          ),
        );
        $formatters['shadowbox_gallery][' . $view_rule . '][' . $shadowbox_rule] = array(
          'label' => 'shadowbox gallery: ' . $view_rule . ' to ' . $shadowbox_rule,
          'field types' => array(
            'image',
          ),
        );
      }
    }
  }
  return $formatters;
}