MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: unmaintained
Implementation Tag
Description Enables embedding the Last.fm player in a page with the <lastfm> tag.
Author(s) Guy Taylor (TheBigGuytalk)
Latest version 0.2 (2008-05-20)
Database changes No
License No license specified
Download See the code section
Translate the LastFm extension if it is available at translatewiki.net
Check usage and version matrix.

The LastFm extension enables embedding the Last.fm player in a page with the <lastfm> tag.


Now you can use the extension with <lastfm>Last.fm-Username</lastfm> in the wiki


  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/LastFm/LastFm.php";
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


 * LastFm extension for MediaWiki
 * @author Guy Taylor
 * @copyright © Guy Taylor
 * @version 0.2
 * @link https://www.mediawiki.org/wiki/Extension:LastFm

if ( !defined( 'MEDIAWIKI' ) ) {
	die( 'This is not a valid entry point.' );

// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'LastFm',
        'author' => 'Guy Taylor',
        'version' => '0.2',
        'url' => 'https://www.mediawiki.org/wiki/Extension:LastFm',
        'description' => 'Allows to adds the Last.fm player to a page with the <tt>&lt;lastfm&gt;</tt> tag'

$wgExtensionFunctions[] = 'wfLastFm';

function wfLastFm() {
    global $wgParser;
    $wgParser->setHook( 'lastfm', 'renderLastFm' );

# The callback function for converting the input text to HTML output
function renderLastFm( $input ) {
    $output = "<!-- Last.fm http://www.last.fm/ -->";
    $output = "<a href=\"http://www.last.fm/user/";
    $output .= htmlspecialchars($input);
    $output .= "/?chartstyle=tracks\">";
    $output .= "<img src=\"http://imagegen.last.fm/tracks/artists/";
    $output .= htmlspecialchars($input);
    $output .= ".gif\" border=\"0\" alt=\"";
    $output .= htmlspecialchars($input);
    $output .= "'s Last.fm Weekly Artists Chart\" /></a>";

    return $output;