function theme_file_upload_help
7.x file.field.inc | theme_file_upload_help($variables) |
Returns HTML for help text based on file upload validators.
Parameters
$variables: An associative array containing:
- description: The normal description for this field, specified by the user.
- upload_validators: An array of upload validators as used in $element['#upload_validators'].
Related topics
2 theme calls to theme_file_upload_help()
- file_field_widget_form in drupal-7.x/
modules/ file/ file.field.inc - Implements hook_field_widget_form().
- image_field_widget_form in drupal-7.x/
modules/ image/ image.field.inc - Implements hook_field_widget_form().
File
- drupal-7.x/
modules/ file/ file.field.inc, line 933 - Field module functionality for the File module.
Code
function theme_file_upload_help($variables) {
$description = $variables['description'];
$upload_validators = $variables['upload_validators'];
$descriptions = array();
if (strlen($description)) {
$descriptions[] = $description;
}
if (isset($upload_validators['file_validate_size'])) {
$descriptions[] = t('Files must be less than !size.', array('!size' => '<strong>' . format_size($upload_validators['file_validate_size'][0]) . '</strong>'));
}
if (isset($upload_validators['file_validate_extensions'])) {
$descriptions[] = t('Allowed file types: !extensions.', array('!extensions' => '<strong>' . check_plain($upload_validators['file_validate_extensions'][0]) . '</strong>'));
}
if (isset($upload_validators['file_validate_image_resolution'])) {
$max = $upload_validators['file_validate_image_resolution'][0];
$min = $upload_validators['file_validate_image_resolution'][1];
if ($min && $max && $min == $max) {
$descriptions[] = t('Images must be exactly !size pixels.', array('!size' => '<strong>' . $max . '</strong>'));
}
elseif ($min && $max) {
$descriptions[] = t('Images must be between !min and !max pixels.', array('!min' => '<strong>' . $min . '</strong>', '!max' => '<strong>' . $max . '</strong>'));
}
elseif ($min) {
$descriptions[] = t('Images must be larger than !min pixels.', array('!min' => '<strong>' . $min . '</strong>'));
}
elseif ($max) {
$descriptions[] = t('Images must be smaller than !max pixels.', array('!max' => '<strong>' . $max . '</strong>'));
}
}
return implode('<br />', $descriptions);
}