You are here

function template_preprocess_text_format_wrapper in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/filter/filter.module \template_preprocess_text_format_wrapper()
  2. 10 core/modules/filter/filter.module \template_preprocess_text_format_wrapper()

Prepares variables for text format wrapper templates.

Default template: text-format-wrapper.html.twig.

Parameters

array $variables: An associative array containing:

  • attributes: An associative array containing properties of the element.

File

core/modules/filter/filter.module, line 378
Framework for handling the filtering of content.

Code

function template_preprocess_text_format_wrapper(&$variables) {
  $variables['aria_description'] = FALSE;

  // Add element class and id for screen readers.
  if (isset($variables['attributes']['aria-describedby'])) {
    $variables['aria_description'] = TRUE;
    $variables['attributes']['id'] = $variables['attributes']['aria-describedby'];

    // Remove aria-describedby attribute as it shouldn't be visible here.
    unset($variables['attributes']['aria-describedby']);
  }
}