function media_preprocess_media_reference_help in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/media.module \media_preprocess_media_reference_help()
- 9 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 310 - Provides media items.
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'] = $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;
}
}
}