You are here

function image_admin_settings in Image 5

Same name and namespace in other branches
  1. 5.2 image.module \image_admin_settings()
  2. 6 image.admin.inc \image_admin_settings()
  3. 7 image.admin.inc \image_admin_settings()

Admin settings callback.

1 string reference to 'image_admin_settings'
image_menu in ./image.module
Implementation of hook_menu

File

./image.module, line 78

Code

function image_admin_settings() {
  _image_check_settings();
  $form['#submit'] = array(
    'image_settings_sizes_submit' => array(),
  );
  $form['image_updated'] = array(
    '#type' => 'hidden',
    '#value' => variable_get('image_updated', time()),
  );
  $form['paths'] = array(
    '#type' => 'fieldset',
    '#title' => t('File paths'),
  );
  $form['paths']['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' => variable_get('file_directory_path', 'files'),
    )),
  );
  $form['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' => t('The dimensions on the "Original" image will be used to resize the images when they are first uploaded. If both dimensions are specified the image will be resized to fit with in that size. If only one dimension is specified the image will be resized to exactly that dimension with the other determined by the image aspect ratio.'),
    '#validate' => array(
      'image_settings_sizes_validate' => array(),
    ),
  );
  $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.
  for ($i = count($sizes); $i < 6; $i++) {
    $sizes['new' . $i] = array(
      'label' => '',
      '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,
    );
    if (_image_is_required_size($key)) {
      $form['image_sizes'][$key]['label']['#attributes'] = array(
        'disabled' => 'disabled',
      );
      $form['image_sizes'][$key]['label']['#required'] = TRUE;
    }
    $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,
    );
  }
  return system_settings_form($form);
}