function imagepicker_upload_form in Image Picker 6.2
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_upload_form()
- 5 imagepicker.module \imagepicker_upload_form()
- 7 imagepicker.upload.inc \imagepicker_upload_form()
1 string reference to 'imagepicker_upload_form'
- imagepicker_quota_ok in ./
imagepicker.functions.inc - Checks quotas
File
- ./
imagepicker.upload.inc, line 35
Code
function imagepicker_upload_form($form_state, $account = FALSE, $admin = FALSE) {
// multiple uploads
$max_uploads = variable_get('imagepicker_max_uploads', 1);
$settings = array(
'imagepicker_upload_link' => array(
'max_uploads' => $max_uploads,
),
);
drupal_add_js(IMAGEPICKER_PATH . '/imagepicker_upload_link.js');
drupal_add_js($settings, 'setting');
if ($account) {
$user = $account;
}
else {
global $user;
}
$form['#attributes']['enctype'] = 'multipart/form-data';
if (variable_get('imagepicker_upload_progress_enabled', 1) && variable_get('imagepicker_uploadprogress_server', '')) {
$form[IMAGEPICKER_UPLOAD_ID] = array(
'#type' => 'hidden',
'#value' => uniqid(),
'#weight' => -50,
);
}
$form['maxmsg'] = array(
'#type' => 'markup',
'#value' => '',
);
for ($ct = 1; $ct <= $max_uploads; $ct++) {
$form['file_upload_' . $ct] = array(
'#type' => 'file',
'#title' => $max_uploads == 1 ? t('Image file') : t('Image file %ct', array(
'%ct' => $ct,
)),
'#required' => $ct == 1 ? TRUE : FALSE,
'#value' => 1,
'#size' => 50,
);
$form['thumb_' . $ct] = array(
'#type' => 'textfield',
'#title' => t('Thumbnail size'),
'#size' => 10,
'#default_value' => isset($user->imagepicker_default_thumbnail_size) ? $user->imagepicker_default_thumbnail_size : variable_get('imagepicker_default_thumbnail_size', 100),
'#description' => t('Size in pixels of thumbnail\'s bigger side'),
'#required' => TRUE,
);
// enforce a max size
$max_scale = variable_get('imagepicker_max_scale', '');
$max_msg = '';
if ($max_scale) {
$max_msg = t('Maximum !t', array(
'!t' => $max_scale . 'px enforced',
));
}
$form['scale_' . $ct] = array(
'#type' => 'textfield',
'#title' => t('Scale image'),
'#size' => 10,
'#default_value' => isset($user->imagepicker_default_scale) ? $user->imagepicker_default_scale : variable_get('imagepicker_default_scale', ''),
'#description' => t('Scale image to this size in pixels if not left empty. !m', array(
'!m' => $max_msg,
)),
);
if (imagepicker_image_check_functions(TRUE) && variable_get('imagepicker_watermark_enable', 0)) {
if (!variable_get('imagepicker_watermark_image', '') && ($user->imagepicker_watermark_image ? $user->imagepicker_watermark_image : FALSE) && $user->imagepicker_watermark_enable) {
$form['watermark_' . $ct] = array(
'#type' => 'checkbox',
'#title' => t('Use watermark'),
'#description' => $max_uploads == 1 ? t('Use watermark on this image.') : t('Use watermark on Image file %ct', array(
'%ct' => $ct,
)),
'#default_value' => $user->imagepicker_watermark_use ? $user->imagepicker_watermark_use : FALSE,
);
$form['watermark_perc_' . $ct] = array(
'#type' => 'textfield',
'#title' => t('JPEG quality'),
'#size' => 10,
'#maxlength' => 3,
'#default_value' => $user->imagepicker_watermark_perc ? $user->imagepicker_watermark_perc : variable_get('image_jpeg_quality', 75),
'#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
);
}
elseif (variable_get('imagepicker_watermark_image', '')) {
$form['watermark_' . $ct] = array(
'#type' => 'value',
'#value' => 1,
);
}
}
$form['title_' . $ct] = array(
'#type' => 'textfield',
'#title' => $max_uploads == 1 ? t('Title') : t('Title for Image file %ct', array(
'%ct' => $ct,
)),
'#description' => t('Add a title for your image'),
);
$form['description_' . $ct] = array(
'#type' => 'textarea',
'#title' => $max_uploads == 1 ? t('Description') : t('Description for Image file %ct', array(
'%ct' => $ct,
)),
'#rows' => 2,
'#cols' => 80,
'#description' => t('Add a description for your image, max. 254 characters.'),
);
if ($ct < $max_uploads) {
$form['link_' . $ct] = array(
'#type' => 'markup',
'#value' => '',
);
}
}
// groups
if (variable_get('imagepicker_groups_enabled', 1) && variable_get('imagepicker_groups_in_upload_enabled', 1)) {
$grouplist = imagepicker_get_groups($admin ? $user : FALSE);
if ($grouplist) {
$form['grouplist'] = array(
'#type' => 'checkboxes',
'#options' => $grouplist,
'#title' => t('Your Groups'),
'#description' => t('Select a group to add your image to.'),
);
}
}
if ($account) {
$form['account'] = array(
'#type' => 'value',
'#value' => $user->uid,
);
}
if ($admin) {
$form['admin'] = array(
'#type' => 'value',
'#value' => 1,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Upload'),
);
if (variable_get('imagepicker_upload_progress_enabled', 1)) {
$form['#suffix'] = imagepicker_upload_progress_busy();
}
return $form;
}