Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MediaHooks.php

function MediaHooks::fieldWidgetSingleElementFormAlter

Implements hook_field_widget_single_element_form_alter().

File

core/modules/media/src/Hook/MediaHooks.php, line 268

Class

MediaHooks
Hook implementations for media.

Namespace

Drupal\media\Hook

Code

public function fieldWidgetSingleElementFormAlter(&$element, FormStateInterface $form_state, $context) : void {
    // Add an attribute so that text editors plugins can pass the host entity's
    // language, 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();
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal