Add lang attribute to the oEmbed iframe page HTML element

The media_oembed_iframe template renders a bare HTML page loaded inside a sandboxed iframe. Without a lang attribute on <html>, assistive technologies cannot determine the language of the embedded content, which violates WCAG 3.1.1 (Language of Page) and WCAG 3.1.2 (Language of Parts).

This adds a langcode variable (populated from the current content language in a preprocess hook) and uses it as lang="{{ langcode }}" on the <html> element.

Modules and themes that need provider-specific behaviour (e.g. adding hl= to a YouTube embed URL) can continue to do so via hook_preprocess_media_oembed_iframe().

Fixes #3593533

Merge request reports

Loading