function image_admin_settings in Image 6
Same name and namespace in other branches
- 5.2 image.module \image_admin_settings()
- 5 image.module \image_admin_settings()
- 7 image.admin.inc \image_admin_settings()
Menu callback; Form builder function for image settings.
1 string reference to 'image_admin_settings'
- image_menu in ./
image.module - Implementation of hook_menu
File
- ./
image.admin.inc, line 6
Code
function image_admin_settings() {
$form['image_updated'] = array(
'#type' => 'hidden',
'#value' => variable_get('image_updated', time()),
);
$form['files'] = array(
'#type' => 'fieldset',
'#title' => t('Image file settings'),
);
$form['files']['image_default_path'] = array(
'#type' => 'textfield',
'#title' => t('Default image path'),
'#default_value' => variable_get('image_default_path', 'images'),
'#description' => t('Subdirectory in the directory %dir where pictures will be stored. Do not include trailing slash.', array(
'%dir' => file_directory_path(),
)),
);
$form['files']['image_max_upload_size'] = array(
'#type' => 'textfield',
'#title' => t('Maximum upload size'),
'#default_value' => variable_get('image_max_upload_size', 800),
'#field_suffix' => t('KB'),
'#size' => 12,
'#description' => t('Maximum file size for image uploads. When a maximum image dimensions is specified for original images the size is checked after resizing.'),
);
$form['image_sizes'] = array(
'#type' => 'fieldset',
'#title' => t('Image sizes'),
'#tree' => TRUE,
'#theme' => 'image_settings_sizes_form',
'#description' => '<p>' . t("The <em>Scale image</em> operation resizes images so that they fit with in the given dimensions. If only one dimension is specified the other dimension will be computed based on the image's aspect ratio. The <em>Scale and crop image</em> operation resizes images to be exactly the given dimensions. If only one dimension is specified the image will not be cropped, making this is equivalent to <em>Scale image</em>.") . '</p>' . '<p>' . t("Note: 'Original' dimensions will only be used to resize images when they are first uploaded. Existing originals will not be modified.") . '</p>',
);
$link_options = array(
IMAGE_LINK_HIDDEN => t('Hidden'),
IMAGE_LINK_SHOWN => t('Same window'),
IMAGE_LINK_NEW => t('New window'),
);
$sizes = image_get_sizes();
// Add some empty rows for user defined sizes.
$num_sizes = count($sizes);
for ($i = $num_sizes; $i < $num_sizes + 3; $i++) {
$sizes['new' . $i] = array(
'label' => '',
'operation' => 'scale',
'width' => '',
'height' => '',
'link' => IMAGE_LINK_SHOWN,
'new' => TRUE,
);
}
foreach ($sizes as $key => $size) {
$form['image_sizes'][$key]['label'] = array(
'#type' => 'textfield',
'#default_value' => $size['label'],
'#size' => 25,
'#maxlength' => 32,
);
// For required sizes, set the value and disable the field.
if (_image_is_required_size($key)) {
$form['image_sizes'][$key]['label']['#disabled'] = TRUE;
$form['image_sizes'][$key]['label']['#value'] = $size['label'];
$form['image_sizes'][$key]['label']['#required'] = TRUE;
}
$form['image_sizes'][$key]['operation'] = array(
'#type' => 'select',
'#default_value' => $size['operation'],
'#options' => array(
'scale' => t('Scale image'),
'scale_crop' => t('Scale and crop image'),
),
);
$form['image_sizes'][$key]['width'] = array(
'#type' => 'textfield',
'#default_value' => $size['width'],
'#size' => 5,
'#maxlength' => 5,
);
$form['image_sizes'][$key]['height'] = array(
'#type' => 'textfield',
'#default_value' => $size['height'],
'#size' => 5,
'#maxlength' => 5,
);
$form['image_sizes'][$key]['link'] = array(
'#type' => 'select',
'#default_value' => $size['link'],
'#options' => $link_options,
);
}
// Make changes to the settings before passing them off to
// system_settings_form_submit().
$form['#submit'][] = 'image_admin_settings_submit';
return system_settings_form($form);
}