function media_preprocess_media_reference_help

Same name in other branches
  1. 9 core/modules/media/media.module \media_preprocess_media_reference_help()
  2. 10 core/modules/media/media.module \media_preprocess_media_reference_help()
  3. 11.x core/modules/media/media.module \media_preprocess_media_reference_help()

Implements hook_preprocess_HOOK() for media reference widgets.

File

core/modules/media/media.module, line 308

Code

function media_preprocess_media_reference_help(&$variables) {
    // Most of these attribute checks are copied from
    // template_preprocess_fieldset(). Our template extends
    // field-multiple-value-form.html.twig to provide our help text, but also
    // groups the information within a semantic fieldset with a legend. So, we
    // incorporate parity for both.
    $element = $variables['element'];
    Element::setAttributes($element, [
        'id',
    ]);
    RenderElement::setAttributes($element);
    $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : [];
    $variables['legend_attributes'] = new Attribute();
    $variables['header_attributes'] = new Attribute();
    $variables['description']['attributes'] = new Attribute();
    $variables['legend_span_attributes'] = new Attribute();
    if (!empty($element['#media_help'])) {
        foreach ($element['#media_help'] as $key => $text) {
            $variables[substr($key, 1)] = $text;
        }
    }
}

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