function template_preprocess_file_managed_file

Same name in other branches
  1. 9 core/modules/file/file.module \template_preprocess_file_managed_file()
  2. 8.9.x core/modules/file/file.module \template_preprocess_file_managed_file()
  3. 11.x core/modules/file/file.module \template_preprocess_file_managed_file()

Prepares variables for file form widget templates.

Default template: file-managed-file.html.twig.

Parameters

array $variables: An associative array containing:

  • element: A render element representing the file.

File

core/modules/file/file.module, line 1033

Code

function template_preprocess_file_managed_file(&$variables) {
    $element = $variables['element'];
    $variables['attributes'] = [];
    if (isset($element['#id'])) {
        $variables['attributes']['id'] = $element['#id'];
    }
    if (!empty($element['#attributes']['class'])) {
        $variables['attributes']['class'] = (array) $element['#attributes']['class'];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.