theme_file_upload_help
function theme_file_upload_help
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
File
- modules/file/file.field.inc, line 940
- 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); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!file!file.field.inc/function/theme_file_upload_help/7.x