You are here

function media_field_widget_form_alter in Drupal 8

Implements hook_field_widget_form_alter().

File

core/modules/media/media.module, line 510
Provides media items.

Code

function media_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {

  // Add an attribute so that "drupalmedia" CKEditor plugin 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();
  }
}