Link Replace Filter

Edited by Vacilando. Last updated 9. August, 2015.

A text filter providing the ability to replace URLs in free text links by URLs taken from another content type and field.

Use case

It is very advantageous not to enter external links directly into free texts (e.g. via a WYSIWYG). It is much more clever to enter references to nodes of another content type that contain the target URLs (e.g. in a Link module field).
The reason is simple: links in a separate content type are concentrated in one place, so you can easily check / correct / manage them. And most importantly, you can re-use them: instead of entering the same link into two or more nodes, you enter references to the node that hold the URL — and if the URL needs any modification in the future, you can achieve it by changing one single node.

The problem is that a link to a node renders the default view mode of the link node, meaning even though you want to link to, the link will point to your own website's node that only contains the target URL.

Some approaches, like Field Redirection or Rabbit Hole let you redirect any request for a node in a given content type to somewhere else. This is sub-optimal because while the direct linking is excellent if you need an external link in the body of an article, the downside is that users cannot ever access the link node directly (which can be useful if you have a link catalogue with tags, descriptions, related links, etc.)
Other approaches will try to enter the target link directly into the text — but that, of course, beats the purpose of re-usability.


Enter Link Replace Filter, a lightweight link replacement system implemented as a text filter. Imagine you have a content type Link that contains a field (provided by the Link module) that contains the target URL. Go to the filters page (/admin/config/content/formats), edit one of the text formats (e.g. Full HTML), and enable the Link Replace Filter. In its settings you only need to enter two pieces of information:

  • Machine name of the target content type — e.g. "link" (if your content type is called Link).
  • Use the Token browser to select a field that contains the target URL, e.g. "[node:field_link]".

Now, the next time you need to enter an external link in a text you are writing, just find and enter (e.g. using the excellent Linkit module) the link to your own node. The LRF module will make sure that when the text is displayed, the URLs (absolute or relative) to nodes of the content type you selected (link) will be replaced by the value of the (Link) field you specified.

More information

Detail installation and configuration instructions, demonstration and other information about this module are at

All comments and patches providing or leading to improvements are welcome in the issue queue. Accepting able co-maintainers with demonstrable vision for this module.

This module is developed and maintained by Tomáš Fülöpp / Vacilando. Any and all donations are welcome via GitTip. The maintainer is available for paid customizations of any Vacilando module, development of new modules, or urgent troubleshooting / patch reviewing.

Project page and download.


In the WYSIWYG edit screen the link below points to URL but thanks to the LRF module it gets replaced to link directly to the XKCD page:

Pale Blue Dot

Related links

Saturday 19. October, 2013, Brussel, Belgium

 Drupal php filter link URL anchor module

Return to the article list.