links_to_iframes_filter
No security coverage
Provides a Drupal text filter that replaces configured links with iframe markup.
What it does
- Stores link to iframe replacements in a custom database table.
- Adds a text filter plugin:
Replace links with iframes. - When enabled on a text format, matching links in processed text are replaced with the configured iframe markup.
Requirements
- Drupal 10 or 11
- Core
filtermodule (declared as a dependency)
Installation
- Enable the module.
- Rebuild caches.
Configuration
- Go to:
/admin/config/content/links-to-iframes - Add one or more replacements:
- Link
- Iframe
- Save replacements.
Enable the filter on a text format
- Go to:
/admin/config/content/formats - Edit the text format you want.
- Enable
Replace links with iframes. - Save the text format.
Matching behavior
- Matches anchors by exact
hrefvalue. - Replacement runs only where that text format is applied.
Example input and output
Configured replacement:
- Link:
https://example.com/embed#swap-for-iframe - Iframe:
<iframe src="https://example.com/embed" frameborder=""></iframe>
Input (text using a format with the filter enabled):
<p>
<a href="https://example.com/embed#swap-for-iframe">Open embed</a>
</p>
Output after filtering:
<p>
<iframe src="https://example.com/embed"></iframe>
</p>
Data storage
- Data is stored in table:
links_to_iframes_filter - Cache tag used by the filter:
links_to_iframes_filter:mappings
Testing
phpunit tests area available in the /tests folder.