Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module makes embedded videos responsive by ensuring iframes from Drupal's core Media oEmbed component fill their containers while maintaining a 16:9 aspect ratio. It automatically applies CSS to fix layout issues on different screen sizes.

This module provides a lightweight solution to make Drupal's core Media oEmbed iframes responsive. By default, Drupal's oEmbed display formatter renders iframes with fixed dimensions, which can break layouts on smaller screens or fail to fill the available width on larger containers. This module applies CSS to ensure iframe.media-oembed-content elements take up 100% of their container's width while maintaining a 16:9 aspect ratio.

REQUIREMENTS

  • Drupal Core: 10.x or 11.x
  • Media: This module relies on the core Media module (standard in Drupal installs).

INSTALLATION

Install as you would normally install a contributed Drupal module. Visit: https://www.drupal.org/node/1897420 for further information.

CONFIGURATION

This module requires no configuration.

Once enabled, it globally attaches a CSS library that targets iframes with the class .media-oembed-content.

The applied styles are:

iframe.media-oembed-content {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9;
}

How it Works

The module implements hook_page_attachments() to inject a small CSS file into every page load. This CSS forces the oEmbed iframe to respond to the width of its parent container using modern CSS aspect-ratio property.

Troubleshooting

My video is not 16:9

Currently, this module enforces a 16:9 aspect ratio, which is standard for most YouTube and Vimeo content. If you need to support other aspect ratios (like 4:3 or 1:1), you may need to override the CSS in your theme or submit a patch to this module to allow configuration.

The styles are not applying

  1. Ensure the module is enabled.
  2. Clear the Drupal cache (drush cr).
  3. Inspect the iframe element in your browser's developer tools. Ensure it has the class media-oembed-content. If your theme or a custom template removes this class, the selectors will not match.

Support development on this module

A lot of hard work and dedication has gone into developing this module. If you find it helpful and would like to support ongoing development, consider buying me a coffee! Your support helps ensure that I can continue enhancing and maintaining this module for everyone. Thank you for your generosity!



Activity

Total releases
1
First release
Jan 2026
Latest release
5 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.x-dev Dev Jan 26, 2026