theme_file_widget

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 theme_file_widget($variables)

Returns HTML for an individual file upload widget.

Parameters

$variables An associative array containing:

  • element: A render element representing the widget.

Related topics

Code

modules/file/file.field.inc, line 780

<?php
function theme_file_widget($variables) {
  $element = $variables['element'];
  $output = '';

  // The "form-managed-file" class is required for proper Ajax functionality.
  $output .= '<div class="file-widget form-managed-file clearfix">';
  if ($element['fid']['#value'] != 0) {
    // Add the file size after the file name.
    $element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> ';
  }
  $output .= drupal_render_children($element);
  $output .= '</div>';

  return $output;
}
?>