You are here

function imagepicker_upload_form in Image Picker 5.2

Same name and namespace in other branches
  1. 5 imagepicker.module \imagepicker_upload_form()
  2. 6.2 imagepicker.upload.inc \imagepicker_upload_form()
  3. 7 imagepicker.upload.inc \imagepicker_upload_form()
1 string reference to 'imagepicker_upload_form'
imagepicker_quota_ok in ./imagepicker.module

File

./imagepicker.module, line 257
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_upload_form($account = FALSE, $admin = FALSE) {
  $form['#attributes']['enctype'] = 'multipart/form-data';
  $form['file_upload'] = array(
    '#type' => 'file',
    '#title' => t('Image file'),
    '#description' => t('Browse your computer for image file'),
    '#required' => TRUE,
    '#value' => 1,
  );
  $form['thumb'] = array(
    '#type' => 'textfield',
    '#title' => t('Thumbnail size'),
    '#size' => 10,
    '#default_value' => variable_get('imagepicker_default_thumbnail_size', 100),
    '#description' => t('Size in pixels of thumbnail\'s bigger side'),
    '#required' => TRUE,
  );
  $form['scale'] = array(
    '#type' => 'textfield',
    '#title' => t('Scale image'),
    '#size' => 10,
    '#default_value' => variable_get('imagepicker_default_scale', ''),
    '#description' => t('Scale image to this size in pixels if not left empty'),
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#description' => t('Add title for your image'),
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#rows' => 2,
    '#cols' => 80,
    '#description' => t('Add description for your image'),
  );

  // groups
  if (variable_get('imagepicker_groups_in_upload_enabled', 1)) {
    $grouplist = imagepicker_get_groups($admin ? $account : FALSE);
    if ($grouplist) {
      $form['grouplist'] = array(
        '#type' => 'checkboxes',
        '#default_value' => '',
        '#options' => $grouplist,
        '#title' => t('Your Groups'),
        '#description' => t('Select a group to add your image to.'),
      );
    }
  }
  if ($account) {
    $form['account'] = array(
      '#type' => 'hidden',
      '#value' => $account->uid,
    );
  }
  if ($admin) {
    $form['admin'] = array(
      '#type' => 'hidden',
      '#value' => 1,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Upload'),
  );
  if (variable_get('imagepicker_upload_progress_enabled', 1)) {
    $form['#suffix'] = theme('imagepicker_upload_progress_busy');
  }
  return $form;
}