Extension:LinkAttributes

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
Link Attributes

Release status:Extension status beta

ImplementationTemplate:Extension#type Extended syntax
DescriptionTemplate:Extension#description Extends the link syntax to allow custom attributes, such as rel="author"
Author(s)Template:Extension#username Leo Wallentin (Rotseetalk)
Latest versionTemplate:Extension#version 0.2 (2015-04-13)
MediaWikiTemplate:Extension#mediawiki 1.19+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license BSD 3-clause "Modified" License
Download
README
Hooks usedTemplate:Extension#hook
LinkerMakeExternalLinkManual:Hooks/LinkerMakeExternalLink
LinkBeginManual:Hooks/LinkBegin

Translate the LinkAttributes extension if it is available at translatewiki.net

Check usage and version matrix.

The LinkAttributes extension extends the link syntax to allow custom attributes, such as rel="author".

Usage[edit]

Extra attributes are added at the end of a link, separated with a pipe (|) or a broken pipe (¦), like this:

 [http://www.twitter.com/me my Twitter account|rel=me]

or

 [[User:Me|my userpage|rel=me]]

Allowed properties are: rel, rev, charset, type, hreflang and itemprop.

In some places (such as inside templates with tables) the pipe can be hard to use, as it has special meanings to MediaWiki. Therefore a broken pipe (¦) will also work with this extension: Oranges¦itemprop=fruit. Note that the following will NOT add an attribute: [[User:James|rel=author]]. The extension has no way of knowing if rel=author is supposed to be an attribute or the actual text to be linked, so the link would have to be written like this: [[User:James|James|rel=author]]. Also note that after installing this extension, pipe characters will no work in link texts.

Installation[edit]

  • Download and place the file(s) in a directory called LinkAttributes in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/LinkAttributes/LinkAttributes.php";
    
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

See also[edit]