You are here

function imagecache_reflect_form in ImageCache Reflect 7

Implements imagecache_hook_form()

Config form for reflect action.

1 string reference to 'imagecache_reflect_form'
imagecache_reflect_image_effect_info in ./imagecache_reflect.module
Implements hook_image_effect_info().

File

./imagecache_reflect.module, line 40
Adds a reflection action for images.

Code

function imagecache_reflect_form($action) {
  $action = (array) $action;
  $default = array(
    'imagecache_reflect_color' => 'White',
    'imagecache_reflect_position' => 'bottom',
    'imagecache_reflect_size' => '50%',
    'imagecache_reflect_transparent_source' => FALSE,
  );
  $action = array_merge($default, (array) $action);
  $form = array();
  $form['imagecache_reflect_color'] = array(
    '#type' => 'textfield',
    '#title' => t('Background color'),
    '#description' => t('A hexadecimal color code preceded by a # or the name of the color can be used. eg. <em>white, blue, green, black, etc</em>'),
    '#default_value' => $action['imagecache_reflect_color'],
    '#size' => 10,
    '#maxlength' => 20,
    '#suffix' => '<div class="imagecache-reflect-color"></div>',
    '#attributes' => array(
      'class' => array(
        'edit-imagecache-reflect-colorpicker',
      ),
    ),
    '#element_validate' => array(
      '_imagecache_reflect_validate_color',
    ),
    '#attached' => array(
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      'js' => array(
        drupal_get_path('module', 'imagecache_reflect') . '/imagecache_reflect.js',
      ),
    ),
  );
  $form['imagecache_reflect_transparent_source'] = array(
    '#type' => 'checkbox',
    '#title' => t('Transparent source image'),
    '#default_value' => $action['imagecache_reflect_transparent_source'],
    '#description' => t('If the image that you are reflecting uses alpha transparency, optionally use a much slower algorithm for creating the images, but one that will preserve the transparency.'),
  );
  $form['imagecache_reflect_position'] = array(
    '#type' => 'radios',
    '#title' => t('Position'),
    '#default_value' => $action['imagecache_reflect_position'],
    '#options' => array(
      'top' => t('Top'),
      'right' => t('Right'),
      'bottom' => t('Bottom'),
      'left' => t('Left'),
    ),
    '#description' => t('The position of the image reflection. Default is bottom.'),
    '#required' => TRUE,
  );
  $form['imagecache_reflect_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Size'),
    '#default_value' => $action['imagecache_reflect_size'],
    '#description' => t('The size of the reflection in pixels. You may append % to the integer to represent percentages.'),
    '#required' => TRUE,
  );
  return $form;
}