diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 712a1ad..322f91f 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -104,7 +104,7 @@ function user_theme() {
       'render element' => 'elements',
     ),
     'username' => array(
-      'variables' => array('account' => NULL, 'attributes' => array(), 'link_options' => array()),
+      'variables' => array('account' => NULL, 'attributes' => array(), 'link_options' => array(), 'trim_length' => NULL),
     ),
   );
 }
@@ -469,14 +469,18 @@ function template_preprocess_username(&$variables) {
     }
   }
 
+  if (!isset($variables['trim_length'])) {
+    $variables['trim_length'] = USERNAME_TRIM_LENGTH;
+  }
+
   // Set the name to a formatted name that is safe for printing and
   // that won't break tables by being too long. Keep an unshortened,
   // unsanitized version, in case other preprocess functions want to implement
   // their own shortening logic or add markup. If they do so, they must ensure
   // that $variables['name'] is safe for printing.
   $name = $variables['name_raw'] = $account->getUsername();
-  if (Unicode::strlen($name) > USERNAME_TRIM_LENGTH) {
-    $name = Unicode::truncate($name, USERNAME_TRIM_LENGTH - 1, FALSE, TRUE);
+  if (Unicode::strlen($name) > $variables['trim_length']) {
+    $name = Unicode::truncate($name, $variables['trim_length'] - 1, FALSE, TRUE);
     $variables['truncated'] = TRUE;
   }
   else {
