imageblock.admin.inc in Image Block 6
File
imageblock.admin.inc
View source
<?php
function imageblock_admin_settings_form() {
$form['imageblock_max_file_size'] = array(
'#type' => 'textfield',
'#title' => t('Maximum file size'),
'#description' => t('Specify the size limit that applies to each image. Enter a value like "512" (bytes), "80K" (kilobytes) or "50M" (megabytes) in order to restrict the allowed file size. If you leave this empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array(
'%limit' => format_size(file_upload_max_size()),
)),
'#default_value' => variable_get('imageblock_max_file_size', 0),
);
$form['imageblock_max_dimensions'] = array(
'#type' => 'textfield',
'#title' => t('Maximum dimensions'),
'#description' => t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height.'),
'#default_value' => variable_get('imageblock_max_dimensions', 0),
);
return system_settings_form($form);
}
function imageblock_admin_settings_form_validate($form, &$form_state) {
$values = $form_state['values'];
foreach (array(
'imageblock_max_file_size',
) as $size) {
if (!empty($values[$size]) && !is_numeric(parse_size($values[$size]))) {
form_error($size, t('The "@field" option must contain a valid value. You can either leave the text field empty or enter a string like "512" (bytes), "80K" (kilobytes) or "50M" (megabytes).', array(
'@field' => t('Maximum upload size per file'),
)));
}
}
foreach (array(
'imageblock_max_dimensions',
) as $resolution) {
if (!empty($values[$resolution]) && !preg_match('/^[0-9]+x[0-9]+$/', $values[$resolution])) {
form_set_error($resolution, t('Please specify a resolution in the format WIDTHxHEIGHT (e.g. 640x480).'));
}
}
}