Magento - How to allow certain tags (iframe, embed) in Magento's CMS editor?

Magento - How to allow certain tags (iframe, embed) in Magento's CMS editor?

August 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - How to allow certain tags (iframe, embed) in Magento's CMS editor?

Allowing Specific HTML Tags in Magento CMS Editor

As an experienced Magento developer, I often encounter clients who want to embed multimedia content like videos or maps within their CMS pages. However, by default, Magento’s WYSIWYG editor doesn’t allow certain tags such as <iframe> and <embed>. This restriction is in place for security reasons, but sometimes we need to override these settings.

Understanding the WYSIWYG Editor

The WYSIWYG (What You See Is What You Get) editor in Magento uses TinyMCE, a JavaScript-based HTML editor. The default configuration of TinyMCE comes with a set of allowed and disallowed tags. To allow specific tags like <iframe> or <embed>, we need to modify this configuration.

Modifying the WYSIWYG Configuration

The configuration for the WYSIWYG editor is defined in XML format under app/design/frontend/[your_package]/[your_theme]/etc/tiny_mce/config.xml. If you don’t have a custom theme, you can create one or modify the configuration of your existing theme.

Here’s how to allow <iframe> tags:

  1. Open the config.xml file.

  2. Find the <advanced_content_filtering> element.

  3. Inside this element, add the following line:

    <allowed_iframe_domains>
      <!--- Allow external domains (e.g., YouTube) -->
      <iframe domain="www.youtube.com" />
      <iframe domain="player.vimeo.com" />
    </allowed_iframe_domains>
    
  4. Save the file.

Allowing Embed Tags

To allow <embed> tags, we need to modify TinyMCE’s valid_elements setting. This is done in JavaScript via the Magento admin configuration.

  1. Open your browser and navigate to the Magento backend.

  2. Go to Stores > Configuration > Content Management.

  3. Expand the WYSIWYG Editor section.

  4. Under TinyMCE Advanced Settings, find the valid_elements field.

  5. Add the following line:

    "embed[width|height|src|type|allowfullscreen]",
    
  6. Save the configuration.

Best Practices

While allowing these tags can provide more flexibility to your content creators, it’s crucial to proceed with caution:

  • Always validate and sanitize user input.
  • Use a trusted third-party service for embedding videos (e.g., YouTube iframe API).
  • Test thoroughly before deploying changes live.
  • Monitor your site for any potential security vulnerabilities.

Remember, allowing these tags can expose your site to Cross-Site Scripting (XSS) attacks if not handled properly. Always err on the side of safety.

Conclusion

Allowing <iframe> and <embed> tags in Magento’s CMS editor requires modifying the WYSIWYG configuration files and admin settings. By following the steps outlined above, you can provide more functionality to your content creators without compromising security.

For a deeper dive into Magento development best practices, feel free to explore our Magento Development Guide at Laravel Company. We cover everything from module creation to performance optimization.

Security API Themes Configuration

Our network