You are here

function canvasactions_canvas2file_form in ImageCache Actions 6.2

Same name and namespace in other branches
  1. 8 canvasactions/canvasactions.inc \canvasactions_canvas2file_form()
  2. 5.3 canvasactions.inc \canvasactions_canvas2file_form()
  3. 5.2 canvasactions.inc \canvasactions_canvas2file_form()
  4. 6 canvasactions.inc \canvasactions_canvas2file_form()
  5. 7 canvasactions/canvasactions.inc \canvasactions_canvas2file_form()

Place a given image under the current canvas

Implementation of imagecache_hook_form()

Parameters

$action array of settings for this action:

Return value

a form definition

File

canvasactions/canvasactions.inc, line 421

Code

function canvasactions_canvas2file_form($action) {
  if (imageapi_default_toolkit() != 'imageapi_gd') {
    drupal_set_message('Overlays are not currently supported by using imagemagick. This effect requires GD image toolkit only.', 'warning');
  }
  $defaults = array(
    'xpos' => '0',
    'ypos' => '0',
    'alpha' => '100',
    'path' => '',
    'dimensions' => 'original',
  );
  $action = array_merge($defaults, (array) $action);
  $form = imagecache_actions_pos_form($action);
  $form['alpha'] = array(
    '#type' => 'textfield',
    '#title' => t('opacity'),
    '#default_value' => $action['alpha'],
    '#size' => 6,
    '#description' => t('Opacity: 0-100. Be aware that values other than 100% may be slow to process.'),
  );
  $form['path'] = array(
    '#type' => 'textfield',
    '#title' => t('file name'),
    '#default_value' => $action['path'],
    '#description' => t('File may be in the "files/" folder, or relative to the Drupal siteroot.'),
    '#element_validate' => array(
      'canvasactions_file2canvas_validate_file',
    ),
  );
  $form['dimensions'] = array(
    '#type' => 'radios',
    '#title' => t('final dimensions'),
    '#default_value' => $action['dimensions'],
    '#options' => array(
      'original' => 'original (dimensions are retained)',
      'background' => 'background (image will be forced to match the size of the background)',
      'minimum' => 'minimum (image may be cropped)',
      'maximum' => 'maximum (image may end up with gaps)',
    ),
    '#description' => t('What to do when the background image is a different size from the source image. Backgrounds are not tiled, but may be arbitrarily large.'),
  );
  return $form;
}