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.

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.
  • 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.

Maintainers

Looking for co-maintainers. See the project page for current maintainers.

Activity

Total releases
2
First release
Jul 2026
Latest release
3 hours ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.1 Stable Jul 17, 2026
1.0.0 Stable Jul 17, 2026