function canvasactions_definecanvas_form in ImageCache Actions 5.2
Same name and namespace in other branches
- 8 canvasactions/canvasactions.inc \canvasactions_definecanvas_form()
- 5.3 canvasactions.inc \canvasactions_definecanvas_form()
- 6.2 canvasactions/canvasactions.inc \canvasactions_definecanvas_form()
- 6 canvasactions.inc \canvasactions_definecanvas_form()
- 7 canvasactions/canvasactions.inc \canvasactions_definecanvas_form()
Implementation of imagecache_hook_form()
Settings for preparing a canvas.
Parameters
$action array of settings for this action:
Return value
a form definition
File
- ./
canvasactions.inc, line 16
Code
function canvasactions_definecanvas_form($action) {
$form = array(
'RGB' => imagecache_rgb_form($action['RGB']),
'help' => array(
'#type' => 'markup',
'#value' => '<p>' . t('Enter no color value for transparent. This will have the effect of adding clear margins around the image.') . '</p>',
),
'under' => array(
'#type' => 'checkbox',
'#title' => t('Resize canvas under image (possibly cropping)'),
'#default_value' => $action['under'],
'#description' => t('If not set, this will create a solid flat layer, probably totally obscuring the source image'),
),
);
$form['info'] = array(
'#value' => t('Enter values in ONLY ONE of the below options. Either exact or relative. Most values are optional - you can adjust only one dimension as needed. If no useful values are set, the current base image size will be used.'),
);
$form['exact'] = array(
'#type' => 'fieldset',
'#collapsible' => true,
'#title' => 'Exact size',
'help' => array(
'#type' => 'markup',
'#value' => '<p>' . t('Set the canvas to a precise size, possibly cropping the image. Use to start with a known size.') . '</p>',
),
'width' => array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $action['exact']['width'],
'#description' => t('Enter a value in pixels or percent'),
'#size' => 5,
),
'height' => array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $action['exact']['height'],
'#description' => t('Enter a value in pixels or percent'),
'#size' => 5,
),
);
$form['exact'] = array_merge($form['exact'], canvasactions_pos_form($action['exact']));
if (!$action['exact']['width'] && !$action['exact']['height']) {
$form['exact']['#collapsed'] = true;
}
$form['relative'] = array(
'#type' => 'fieldset',
'#collapsible' => true,
'#title' => t('Relative size'),
'help' => array(
'#type' => 'markup',
'#value' => '<p>' . t('Set the canvas to a relative size, based on the current image dimensions. Use to add simple borders or expand by a fixed amount. Negative values may crop the image.') . '</p>',
),
'leftdiff' => array(
'#type' => 'textfield',
'#title' => t('left difference'),
'#default_value' => $action['relative']['leftdiff'],
'#size' => 6,
'#description' => t('Enter an offset in pixels.'),
),
'rightdiff' => array(
'#type' => 'textfield',
'#title' => t('right difference'),
'#default_value' => $action['relative']['rightdiff'],
'#size' => 6,
'#description' => t('Enter an offset in pixels.'),
),
'topdiff' => array(
'#type' => 'textfield',
'#title' => t('top difference'),
'#default_value' => $action['relative']['topdiff'],
'#size' => 6,
'#description' => t('Enter an offset in pixels.'),
),
'bottomdiff' => array(
'#type' => 'textfield',
'#title' => t('bottom difference'),
'#default_value' => $action['relative']['bottomdiff'],
'#size' => 6,
'#description' => t('Enter an offset in pixels.'),
),
);
if (!$action['relative']['leftdiff'] && !$action['relative']['rightdiff'] && !$action['relative']['topdiff'] && !$action['relative']['bottomdiff']) {
$form['relative']['#collapsed'] = true;
}
$form['#submit'][] = 'canvasactions_definecanvas_form_submit';
return $form;
}