Skip to content

Instantly share code, notes, and snippets.

@massiws
Last active February 4, 2016 12:40
Show Gist options
  • Save massiws/60c4c7f473f688ed0847 to your computer and use it in GitHub Desktop.
Save massiws/60c4c7f473f688ed0847 to your computer and use it in GitHub Desktop.
Drupal: change maxlength and size of description field in default upload widget
<?php
/**
* @file
* The description used as label of the link to the uploaded file has default lentgh=128 and size=60.
* With this function inside your custom module you can change these (and other) default options.
*/
/**
* Implements hook_preprocess_file_widget().
*/
function msw_custom_preprocess_file_widget(&$vars) {
if (isset($vars['element']['#file']) && is_object($vars['element']['#file'])) {
$vars['element']['description']['#maxlength'] = 600;
$vars['element']['description']['#size'] = 120;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment