You are here

function canvasactions_aspect_form in ImageCache Actions 7

Same name and namespace in other branches
  1. 8 canvasactions/canvasactions.inc \canvasactions_aspect_form()
  2. 6.2 canvasactions/canvasactions.inc \canvasactions_aspect_form()
  3. 6 canvasactions.inc \canvasactions_aspect_form()

Image effect form callback for the aspect switcher effect.

Parameters

array $data: The current configuration for this image effect.

Return value

array The form definition for this effect.

1 string reference to 'canvasactions_aspect_form'
imagecache_canvasactions_image_effect_info in canvasactions/imagecache_canvasactions.module
Implements hook_image_effect_info().

File

canvasactions/canvasactions.inc, line 818

Code

function canvasactions_aspect_form(array $data) {
  $defaults = array(
    'ratio_adjustment' => 1,
    'portrait' => '',
    'landscape' => '',
  );
  $data = array_merge($defaults, (array) $data);
  $form = array(
    'help' => array(
      '#markup' => t('You must create the two presets to use <em>before</em> enabling this process.'),
    ),
  );

  // The PASS_THROUGH parameter is new as of D7.23, and is added here to prevent
  // image_style_options() from double-encoding the human-readable image style
  // name, since the form API will already sanitize options in a select list.
  $styles = image_style_options(TRUE, PASS_THROUGH);

  // @todo: remove the current style to prevent (immediate) recursion?
  $form['portrait'] = array(
    '#type' => 'select',
    '#title' => t('Style to use if the image is portrait (vertical)'),
    '#default_value' => $data['portrait'],
    '#options' => $styles,
    '#description' => t('If you choose none, no extra processing will be done.'),
  );
  $form['landscape'] = array(
    '#type' => 'select',
    '#title' => t('Style to use if the image is landscape (horizontal)'),
    '#default_value' => $data['landscape'],
    '#options' => $styles,
    '#description' => t('If you choose none, no extra processing will be done.'),
  );
  $form['ratio_adjustment'] = array(
    '#type' => 'textfield',
    '#title' => t('Ratio Adjustment (advanced)'),
    '#size' => 3,
    '#default_value' => $data['ratio_adjustment'],
    '#description' => t("\nThis allows you to bend the rules for how different the proportions need to be to trigger the switch.\n<br/>If the (width/height)*n is greater than 1, use 'landscape', otherwise use 'portrait'.\n<br/>When n = 1 (the default) it will switch between portrait and landscape modes.\n<br/>If n > 1, images that are slightly wide will still be treated as portraits.\nIf n < 1 then blunt portraits will be treated as landscape.\n    "),
  );
  return $form;
}