Extension:FaviconLink
From MediaWiki.org
|
FaviconLink Release status: unknown |
|
|---|---|
| Implementation | Tag |
| Description | Grabs the favicon from the site you are linking to, and puts it in front of the link |
| Author(s) | FlappySocks |
| Last version | 1.0 |
| License | No license specified |
| Download | see below |
| Check usage and version matrix | |
Introduction [edit]
Grabs the favicon from the site you're linking to, and puts it in front of the link
Download and Installation [edit]
Step 1: Copy-paste this code into a file FaviconLink.php and place it in extensions directory.
<?php # FaviconLink MediaWiki extension # # To activate the extension, include it from your LocalSettings.php # with: require_once ("extensions/FaviconLink.php"); $wgExtensionCredits['specialpage'][] = array( 'name' => 'FaviconLink', 'author' => 'FlappySocks', 'url' => 'http://www.mediawiki.org/wiki/Extension:FaviconLink', 'description' => 'Grabs the favicon from the site you\'re linking to, and puts it in front of the link.' ); $wgExtensionFunctions[] = "wfFaviconLink"; function wfFaviconLink() { global $wgParser; $wgParser->setHook( "ilink", "FaviconLink" ); } # The callback function for converting the input text to HTML output function FavIconLink( $input) { //Look for the start of the URL $pt1 = strpos($input, "://"); if ($pt1===false) $input="http://".$input; //Look for the end of the domain $pt1 = strpos($input, "/",9); if ($pt1===false) $pt1 = strpos($input, " ",9); if ($pt1===false) $pt1 = strlen($input); $favicon = substr($input, 0, $pt1)."/favicon.ico"; //Look for the name/description $pt2 = strpos($input, " ",$pt1); if ($pt2===false) { $link=$input; $linkname = $link; } else { $link=substr($input, 0, $pt2); $linkname = substr($input, $pt2+1); } $favicon = htmlspecialchars($favicon); $linkname = htmlspecialchars($linkname); $link = htmlspecialchars($link); return '<a href="'.$link.'"><img src="'.$favicon.'"> '.$linkname.'</a>'; }
Step 2: Add the following line to LocalSettings.php:
include ("extensions/FaviconLink.php");
Step 3: Add links to your page using <ilink> </ilink> For example.
<ilink>http://www.google.co.uk Google</ilink>
See also [edit]
- Extension:IconLink is as an enhanced version of Extension:FaviconLink, but implemented as a parser function so that it can be used in templates too.
- Extension:ImageLink provides, amongst other things, favicon support through the parser function #iconlink
