function media_field_widget_single_element_form_alter

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

Implements hook_field_widget_single_element_form_alter().

File

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

Code

function media_field_widget_single_element_form_alter(&$element, FormStateInterface $form_state, $context) {
    // Add an attribute so that text editors plugins can pass the host entity's
    // language to EditorMediaDialog, allowing it to present entities in the same
    // language.
    if (!empty($element['#type']) && $element['#type'] == 'text_format') {
        $element['#attributes']['data-media-embed-host-entity-langcode'] = $context['items']->getLangcode();
    }
}

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