You are here

function iek_image_filter_form in Image effect kit 7

Effect configuration form for iek_image_filter.

1 string reference to 'iek_image_filter_form'
iek_image_effect_info in ./iek.module
Implements hook_image_effect_info().

File

./iek.module, line 1013
Primarily Drupal hooks and global API functions to manipulate image styles.

Code

function iek_image_filter_form($data, &$form_state = NULL) {
  $filters = iek_get_image_filters();
  $int127 = array();
  $int255 = array();
  for ($i = 0; $i <= 255; $i++) {
    if ($i <= 127) {
      $int127[$i] = $i;
    }
    $int255[$i] = $i;
  }
  $form['filter_name'] = array(
    '#id' => 'filter_name',
    '#type' => 'select',
    '#title' => t('Filter name'),
    '#description' => t('Choose a filter.'),
    '#options' => $filters,
    '#default_value' => isset($data['filter_name']) ? $data['filter_name'] : '',
    '#required' => TRUE,
  );
  $form['repeat'] = array(
    '#type' => 'select',
    '#options' => $int255,
    '#title' => t('Repeat'),
    '#description' => t('How many times do you want to repeat the filter action? <br>Caution: higher repeat times will cause your site performance issue.'),
    '#default_value' => isset($data['repeat']) ? $data['repeat'] : 1,
    '#required' => TRUE,
  );
  $form['arg1'] = array(
    '#type' => 'select',
    '#options' => $int255,
    '#title' => t('arg1'),
    '#default_value' => isset($data['arg1']) ? $data['arg1'] : 10,
    '#required' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[id=filter_name]' => array(
          array(
            'value' => IMG_FILTER_BRIGHTNESS,
          ),
          array(
            'value' => IMG_FILTER_CONTRAST,
          ),
          array(
            'value' => IMG_FILTER_COLORIZE,
          ),
          array(
            'value' => IMG_FILTER_SMOOTH,
          ),
          array(
            'value' => IMG_FILTER_PIXELATE,
          ),
        ),
      ),
    ),
  );
  $form['arg2'] = array(
    '#type' => 'select',
    '#options' => $int255,
    '#title' => t('arg2'),
    '#default_value' => isset($data['arg2']) ? $data['arg2'] : 0,
    '#required' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[id=filter_name]' => array(
          array(
            'value' => IMG_FILTER_COLORIZE,
          ),
          array(
            'value' => IMG_FILTER_PIXELATE,
          ),
        ),
      ),
    ),
  );
  $form['arg3'] = array(
    '#type' => 'select',
    '#options' => $int255,
    '#title' => t('arg3'),
    '#default_value' => isset($data['arg3']) ? $data['arg3'] : 0,
    '#required' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[id=filter_name]' => array(
          array(
            'value' => IMG_FILTER_COLORIZE,
          ),
        ),
      ),
    ),
  );
  $form['arg4'] = array(
    '#type' => 'select',
    '#options' => $int127,
    '#title' => t('arg4'),
    '#default_value' => isset($data['arg4']) ? $data['arg4'] : 0,
    '#required' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[id=filter_name]' => array(
          array(
            'value' => IMG_FILTER_COLORIZE,
          ),
        ),
      ),
    ),
  );
  return $form;
}