You are here

function seven_preprocess_image_widget in Drupal 10

Same name and namespace in other branches
  1. 9 core/themes/seven/seven.theme \seven_preprocess_image_widget()

Implements hook_preprocess_image_widget().

File

core/themes/seven/seven.theme, line 417
Functions to support theming in the Seven theme.

Code

function seven_preprocess_image_widget(array &$variables) {
  $data =& $variables['data'];

  // This prevents image widget templates from rendering preview container HTML
  // to users that do not have permission to access these previews.
  // @todo revisit in https://drupal.org/node/953034
  // @todo revisit in https://drupal.org/node/3114318
  if (isset($data['preview']['#access']) && $data['preview']['#access'] === FALSE) {
    unset($data['preview']);
  }

  // @todo Revisit everything in this conditional in
  //   https://drupal.org/node/3117430
  if (!empty($variables['element']['fids']['#value'])) {
    $file = reset($variables['element']['#files']);
    $data["file_{$file->id()}"]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file
      ->getSize()) . ')</span> ';
  }
}