Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

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
2 months ago
Release cadence
Stability
0% stable

Releases

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