Loading core/modules/file/file.module +1 −0 Original line number Diff line number Diff line Loading @@ -1502,6 +1502,7 @@ function template_preprocess_file_link(&$variables) { // Set file classes to the options array. $variables['attributes'] = new Attribute($variables['attributes']); $variables['attributes']->addClass($classes); $variables['file_size'] = format_size($file->getSize()); $variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options)); } Loading core/modules/file/templates/file-link.html.twig +5 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ * Available variables: * - attributes: The HTML attributes for the containing element. * - link: A link to the file. * - file_size: The size of the file. * * @see template_preprocess_file_link() * Loading @@ -13,3 +14,7 @@ */ #} <span{{ attributes }}>{{ link }}</span> {% if file_size %} {# @todo remove class before Drupal 9.0.0 #} <span class="file-size">({{ file_size }})</span> {% endif %} core/modules/image/image.field.inc +0 −5 Original line number Diff line number Diff line Loading @@ -21,11 +21,6 @@ function template_preprocess_image_widget(&$variables) { $variables['attributes'] = ['class' => ['image-widget', 'js-form-managed-file', 'form-managed-file', 'clearfix']]; if (!empty($element['fids']['#value'])) { $file = reset($element['#files']); $element['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> '; } $variables['data'] = []; foreach (Element::children($element) as $child) { $variables['data'][$child] = $element[$child]; Loading core/themes/classy/templates/field/file-link.html.twig +2 −0 Original line number Diff line number Diff line Loading @@ -7,8 +7,10 @@ * - attributes: The HTML attributes for the containing element. * - link: A link to the file. * - icon: The icon image representing the file type. * - file_size: The size of the file. * * @see template_preprocess_file_link() * @see stable_preprocess_image_widget() */ #} {{ attach_library('classy/file') }} Loading core/themes/stable/stable.theme +10 −0 Original line number Diff line number Diff line Loading @@ -23,3 +23,13 @@ function stable_preprocess_links(&$variables) { } } } /** * Implements hook_preprocess_image_widget(). */ function stable_preprocess_image_widget(&$variables) { if (!empty($variables['element']['fids']['#value'])) { $file = reset($variables['element']['#files']); $variables['data']['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> '; } } Loading
core/modules/file/file.module +1 −0 Original line number Diff line number Diff line Loading @@ -1502,6 +1502,7 @@ function template_preprocess_file_link(&$variables) { // Set file classes to the options array. $variables['attributes'] = new Attribute($variables['attributes']); $variables['attributes']->addClass($classes); $variables['file_size'] = format_size($file->getSize()); $variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options)); } Loading
core/modules/file/templates/file-link.html.twig +5 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ * Available variables: * - attributes: The HTML attributes for the containing element. * - link: A link to the file. * - file_size: The size of the file. * * @see template_preprocess_file_link() * Loading @@ -13,3 +14,7 @@ */ #} <span{{ attributes }}>{{ link }}</span> {% if file_size %} {# @todo remove class before Drupal 9.0.0 #} <span class="file-size">({{ file_size }})</span> {% endif %}
core/modules/image/image.field.inc +0 −5 Original line number Diff line number Diff line Loading @@ -21,11 +21,6 @@ function template_preprocess_image_widget(&$variables) { $variables['attributes'] = ['class' => ['image-widget', 'js-form-managed-file', 'form-managed-file', 'clearfix']]; if (!empty($element['fids']['#value'])) { $file = reset($element['#files']); $element['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> '; } $variables['data'] = []; foreach (Element::children($element) as $child) { $variables['data'][$child] = $element[$child]; Loading
core/themes/classy/templates/field/file-link.html.twig +2 −0 Original line number Diff line number Diff line Loading @@ -7,8 +7,10 @@ * - attributes: The HTML attributes for the containing element. * - link: A link to the file. * - icon: The icon image representing the file type. * - file_size: The size of the file. * * @see template_preprocess_file_link() * @see stable_preprocess_image_widget() */ #} {{ attach_library('classy/file') }} Loading
core/themes/stable/stable.theme +10 −0 Original line number Diff line number Diff line Loading @@ -23,3 +23,13 @@ function stable_preprocess_links(&$variables) { } } } /** * Implements hook_preprocess_image_widget(). */ function stable_preprocess_image_widget(&$variables) { if (!empty($variables['element']['fids']['#value'])) { $file = reset($variables['element']['#files']); $variables['data']['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> '; } }