Extension:Link Attributes

MediaWiki extensions manual
OOjs UI icon advanced.svg
Link Attributes
Release status: stable
Implementation Parser function
Description Adds support for the rel, rev and class attributes on links
Author(s) Toby Inkster, Dennis Roczek (Dennisroczektalk)
Latest version 1.1 (2015-05-05)
MediaWiki 1.23
Database changes No
License GNU General Public License 2.0 or later
Translate the Link Attributes extension if it is available at translatewiki.net
Check usage and version matrix.

This extension adds support for the rel, rev and class attributes on links.

The syntax is a little unorthodox. To set the rel attribute, place one or more tokens in double-parentheses at the end of the link title. e.g.:

  [http://tobyinkster.co.uk/ My website((me home))]

The above would be converted to the following link:

  <a href="http://tobyinkster.co.uk/" rel="me home" class="external">My website</a>

To set the class attribute, the same syntax is used, but tokens which represent classes are prefixed with a dot:

  [http://tobyinkster.co.uk/ My website((me .class1 home .class2))]


  <a href="http://tobyinkster.co.uk/" rel="me home" class="external class1 class2">My website</a>

Similarly, prefixing with a tilde (~) sets the rev attribute.

Tokens may be prefixed by a minus sign (-) to indicate that you don't want to add the token, but remove it. For example:

  [http://tobyinkster.co.uk/ My website((me -.external home))]


  <a href="http://tobyinkster.co.uk/" rel="me home">My website</a>

The "nofollow" rel token is considered untouchable though.


You need to patch includes/Linker.php. Find the makeExternalLink function and replace the existing wfRunHooks line with the following:

  $success = wfRunHooks('LinkerMakeExternalLink', array( &$url, &$text, &$link, &$attribs, $linktype, $this ) );

Add the following to LocalSettings.php:

  require_once "$IP/extensions/linkAttributes/linkAttributes.php";

See alsoEdit