You are here

function imageinfo_cache_cck_widget_form in Imageinfo Cache 6

Same name and namespace in other branches
  1. 6.2 imageinfo_cache.admin.inc \imageinfo_cache_cck_widget_form()

Called from imageinfo_cache_form_alter().

1 call to imageinfo_cache_cck_widget_form()
imageinfo_cache_form_alter in ./imageinfo_cache.module
Implements hook_form_alter().

File

./imageinfo_cache.admin.inc, line 126
Configuration page for imageinfo cache module.

Code

function imageinfo_cache_cck_widget_form(&$form, $form_state, $form_id) {
  $widget_settings = variable_get('imageinfo_cache_cck_widget_' . $form['#field']['type_name'] . '_' . $form['#field']['field_name'], array());
  $all = FALSE;
  if (!is_array($widget_settings) && $widget_settings == TRUE) {
    $all = TRUE;
  }

  // Add in settings form.
  $form['widget']['imageinfo_cache'] = array(
    '#type' => 'fieldset',
    '#title' => t('Imageinfo Cache'),
    '#collapsible' => 1,
    '#collapsed' => 1,
    '#weight' => 20,
  );
  $form['widget']['imageinfo_cache']['imageinfo_cache_settings_all'] = array(
    '#type' => 'checkbox',
    '#title' => t('Select all imagecache presets to pregenerate when an image is uploaded'),
    '#default_value' => $all,
    '#description' => t('If selected the settings below will be ignored.'),
  );
  foreach (imagecache_presets() as $preset) {
    $presets[$preset['presetid']] = $preset['presetname'];
  }
  $form['widget']['imageinfo_cache']['imageinfo_cache_settings'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select the imagecache presets to pregenerate when an image is uploaded'),
    '#options' => $presets,
    '#default_value' => $all ? array_flip($presets) : $widget_settings,
  );

  // Add in submit handler.
  if (!in_array('imageinfo_cache_cck_widget_form_submit', $form['#submit'])) {
    $form['#submit'][] = 'imageinfo_cache_cck_widget_form_submit';
  }
}