Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Usage Milestone: Time Field for Drupal 8+ Module time_field crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Media Embed Code

4 sites No security coverage Drupal 10–11
View on drupal.org

This module introduces a new media type for embedding third-party scripts and iframe snippets, such as social widgets or tracking codes. Editors can add these embed codes through the Media Library and reuse them across the site, Centralizing and managing them as media entities. This allows for safe embedding of such content without directly pasting raw markup into content fields.

The Media Embed Code module adds an "Embed Code" media type, giving site builders a clean, reusable way to store and embed third-party script and iframe snippets — social widgets, ad tags, tracking pixels, chat widgets, maps, and similar embeds — as media entities, rather than pasting raw markup directly into body fields or templates.

Once installed, editors can add an "Embed Code" media item through the standard Media Library, paste in the third-party snippet, and reference it anywhere media entities are supported: media reference fields, views, and the CKEditor 5 Media Library button in any text format.

Features

  • A dedicated Embed Code media type, field type, and field formatter, ready to use immediately after installation.
  • A media source plugin so Embed Code integrates natively with the Media Library, media reference fields, and CKEditor 5.
  • A CKEditor 5 preview safeguard: when an Embed Code media item is shown inside the editor's live preview or "Preview" tab, the module automatically substitutes a safe thumbnail-based display instead of executing the embedded script/iframe inline in the editing surface.
  • A configurable "Allowed HTML tags" field setting, letting site builders restrict which tags (e.g. iframe, script, embed) editors may enter into a given Embed Code field. Content with a disallowed tag is blocked from saving with a validation error naming the offending tag(s); the setting defaults to allowing any tag.
  • No dependencies beyond Drupal core's Media and Media Library modules — nothing else required.

Use cases

  • Centralizing third-party embed snippets (analytics, ad tags, marketing widgets) as manageable, reusable content instead of scattering raw HTML across body fields.
  • Letting trusted editors embed scripts through the Media Library UI without giving them a text format that allows arbitrary HTML everywhere.
  • Auditing and reusing the same embed code across multiple pages from a single media entity.

Security considerations

Embed Code media renders its stored value as unsanitized, trusted markup by design — third-party embed snippets frequently require <script> or <iframe> tags to function.
This means anyone able to create or edit Embed Code media can execute arbitrary JavaScript on any page where that media item appears.

Site builders must restrict the dynamically-generated "Embed Code: Create new media" and "Embed Code: Edit own/any media" permissions to trusted, administrative roles only.
See the module's README for full details.

Requirements

  • Drupal core's Media module
  • Drupal core's Media Library module
  • Drupal ^10.3 or ^11

No contributed module dependencies.

Depends on

Dependencies of the latest stable release

  • media Drupal core
  • media_library Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

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

Release Timeline

Releases

Version Type Core Release date
1.0.3 Stable 10–11 Aug 21, 2026
1.0.2 Stable 10–11 Jul 20, 2026
1.0.1 Stable 10–11 Jul 17, 2026
1.0.0 Stable 10–11 Jul 17, 2026