Extension:Title Icon

The Title Icon extension places an icon beside the page title when the title is displayed at the top of the page and when the page is listed in search results. Display of such an icon can help users easily visually detect that a page is in a particular category or namespace. This helps on the page itself, but also helps when trying to pick out the correct page from a list of search results.

The icon is specified in a parser function as a filename of an image file uploaded to the wiki, an OOUI icon, or a Unicode sequence or by a Semantic MediaWiki property value of type Text that is the filename of an image file uploaded to the wiki. The extension looks for the icons defined on the page itself, on the category page of any category to which the page belongs, and on the page in the Project namespace with the name of the page's namespace (e.g. the page Fruit:Apple would have its namespace icon specified on page Project:Fruit with the namespaces localized in the content language and the Main namespace indicated by the value on page MediaWiki:Blanknamespace including the parentheses). Multiple icons will be displayed where multiple icons are assigned to the page (limited to a maximum of five semantic properties on the page itself and its categories). However, if the same icon is specified more than once, it will only be displayed once. File icons are sized to 36 pixels by 36 pixels maintaining its original aspect ratio.

By default, Title Icon will insert the icon in the title at the top of a page for any skin that puts the title in an HTML element with id   such as the default Vector skin. This can be changed for other skins using the  configuration variable. This approach can also be used to have the Title Icon appear at other places in the page by using a and appropriate choice of.

Special thanks to Bernadette Clemente for the original idea that inspired this extension and to Keven Ring for an early implementation of this extension.

Configuration
NOTE: The  and   parameters were removed in version 2.0 since they duplicate and conflict with functionality provided by the Semantic Title extension.

Parser Functions
Four parser functions were introduced in TitleIcon version 5.0.

titleicon_*
Three parser functions can be used to define title icons on wiki pages:

where  is the name of the file page containing the image (  namespace will be added to   if it is not included)

where  is the OOUI SVG filename without the path, e.g.

For example, the following results in a title icon of &#x1F469;&#x1F3FE;&zwj;&#x1F4BB; linked to the page  displayed on the page's title bar and beside the page title in searches:

hidetitleicon
will hide title icons on the current page.


 * : hide all title icons defined on this page
 * : hide all title icons defined in all categories this page belongs to
 * : hide all title icons defined on the namespace page (e.g. Project:&lt;namespace>) for this page
 * : hide all title icons on this page

This can be combined with the semantic property approach to hiding title icons described below. The main difference is that the Semantic MediaWiki approach will work on search results while the parser function only works on the page itself.

Semantic MediaWiki
While this extension does not require Semantic MediaWiki to be installed, if it is installed, Semantic MediaWiki can be used to define file type title icons and hide title icons on pages as shown below.

 Category:Title Icon Example :

 Title Icon Example 1 :

 Title Icon Example 2 :

 Title Icon Example 3 :

 Title Icon Example 4 :

 Title Icon Example 5 :



API
As of version 5.1, Title Icon provides an action API query module. The query takes the name of the query and a list of titles (e.g.  ). The result will be a JSON encoded array of the title icons for the requested pages. For example, the query  could result in something like:

{   "batchcomplete": "", "query": { "pages": { "1": {               "pageid": 1, "ns": 0, "title": "Main Page", "titleicons": "" }       }    } }

This corresponds to a unicode icon &#x1F469;&#x1F3FE;&zwj;&#x1F4BB; defined on  an OOUI icon   defined on the category page   (since in this example,   is in category  ) that is linked to the page , and a file icon   defined for the main namespace (by placing a title icon on page  ).

Release Notes

 * Version 6.1
 * Fix broken deserialization from page properties
 * Avoid an exception when the title is malformed


 * Version 6.0
 * Dropped support for MediaWiki 1.37 and below (required by internal code improvements)


 * Version 5.2
 * Dropped requirement that file icons include the File: namespace in the icon name (although they still refer to files in the File: namespace; the File: gets added automatically now if it is missing)
 * Changes the save of icon page properties to ParserAfterParse hook
 * Improved tests


 * Version 5.1
 * Added MediaWiki action API support to query Title Icons


 * Version 5.0
 * Added support for OOUI icons and Unicode sequences
 * Added parser functions: titleicon_file, titleicon_ooui, titleicon_unicode, hidetitleicon
 * Added support for specifying title icons per namespace
 * Continued support for Semantic MediaWiki
 * Non-Semantic MediaWiki (parser function) defined icons accessible as page properties
 * Refactored code to current coding standards
 * Dropped support for MediaWiki 1.34 and below


 * Version 4.1.1
 * Replace use of $wgParser with dependency injection facility


 * Version 4.1
 * Fixed to work with Semantic MediaWiki 3.0.0 (Undefined class constant 'TYPE_STRING')


 * Version 4.0
 * Fixes rendering in search results which breaks compatbility with MediaWiki 1.27 and lower


 * Version 3.0
 * Removed use of inline JavaScript that caused issues in MediaWiki 1.26
 * Converted to new extension registration style
 * Removed support for old style i18n and extension registration
 * Renamed configuration variables with $wg prefix to support new extension registration format


 * Version 2.2
 * Added  and updated coding style