Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: ECA: Event - Condition - Action 3.1.9 Minor update available for module eca (3.1.9). Release: Site verification 3.0.1 Minor update available for module site_verify (3.0.1). Release: Translate Drupal with GTranslate 3.0.6 Minor update available for module gtranslate (3.0.6). Usage Milestone: Entity Browser Module entity_browser crossed 100,000 active installs. Release: Drupal Website Dashboard 1.0.1 Minor update available for module webdashboard (1.0.1). Release: CKEditor5 Table Colors 1.0.5 Minor update available for module ckeditor5_table_colors (1.0.5). Release: Static Suite 1.2.17 Minor update available for module static_suite (1.2.17). Release: GovNL Logging 1.0.1 Minor update available for module govnl_logging (1.0.1). Release: Audit Chain 1.10.0 Minor update available for module audit_chain (1.10.0). Module Revived: Twig Toolkit 1.0.4 Module twig_toolkit updated after 6 months of inactivity (1.0.4).

Iframe Autoheight

No security coverage

Part of the Iframe ecosystem · 6 projects

View on drupal.org

Some embedded pages know how tall they are and say so, posting their content height to the page that frames them. Drupal has no way to listen. The iframe is stuck at whatever fixed height the field was given, so a tall embed gets its own scrollbar inside your page and a short one leaves an empty gap below it.

This module listens. It extends the Iframe field with an allowlist of trusted origins, and any iframe field whose source matches one of them is resized to the height it reports, as often as it reports it. The result is a single page scroll instead of a scrollbar nested inside another.

Nothing is injected into the embedded document. This module is the receiving half only, so it works with embeds you do not control, as long as the provider already posts its height.

Features

  • Resizes an Iframe field to the content height its embed reports, growing and shrinking as the content changes.
  • Per-origin allowlist. An iframe is only ever resized by the document it actually loaded, verified on both the message origin and the sending window, so no other page can resize your embeds.
  • No JavaScript library is added to the embedded document, and none is required there beyond the messages it already sends.
  • Optional scroll assist: an embed that walks the user through steps can ask for the top of the iframe to be brought back into view when the step changes.
  • Until the first message arrives the iframe keeps the height its field defines, so nothing jumps on page load.
  • The script and its settings are only added to pages that actually render an Iframe field.

Typical use cases are third party wizards, questionnaires, calculators, booking flows and configurators, that is any embed whose height changes as the visitor moves through it.

Post-Installation

Go to Configuration › Media › Iframe autoheight (/admin/config/media/iframe-autoheight) and add one row per embed.

Each row takes two values:

  • Origin: the scheme and domain the embed is served from, for example https://www.example.com. Nothing after the domain, because that is all a browser reports when it delivers a message.
  • Message prefix: the namespace the embed puts on the messages it posts. A prefix of example means the embed sends example:iframe-height. You cannot choose this freely, it has to be the one the embed already sends, so ask the provider. A wrong prefix fails silently: the embed simply never resizes.

There is nothing else to configure. No new content type, no text format change, and no per-field setting: every Iframe field on the site whose source matches a configured origin is handled, whichever formatter it uses. Every other iframe keeps the height its field defines.

For embed providers, the contract is two messages posted to window.parent:

  • { type: '<prefix>:iframe-height', height: <pixels> } sets the iframe height. height must be a positive number.
  • { type: '<prefix>:step-change' } scrolls the top of the iframe into view, and only when the visitor has already scrolled past it.

Additional Requirements

Iframe, which provides the field type this module extends. No external libraries and no Composer dependencies beyond that.

None. The module is self contained once Iframe is installed.

Similar projects

iFrame Resizer solves the same problem from the other end: it ships the iframe-resizer JavaScript library, which has to run inside the embedded document as well as in the parent. That gives you more features, including in-page links and nested iframes, but it only works when you control the embedded page or the provider agrees to load the library. It is also not tied to the Iframe field, so it can target any iframe on the page.

Use iFrame Resizer when you own both sides. Use this module when you own only the Drupal side and the embed already reports its height in its own format.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Sep 2026
Latest release
4 hours ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
1.0.x-dev Dev 10–11 Sep 22, 2026