Jump to content

Extension:LinkCards

From mediawiki.org
MediaWiki extensions manual
LinkCards
Release status: experimental
Implementation Parser function
Description Easy display of clickable image-and-title 'cards', in grids or columns.
Author(s) Sam Wilson (Samwilsontalk)
Latest version 0.9.0 (2024-11-07)
Compatibility policy Master maintains backward compatibility.
MediaWiki >= 1.35.0
Database changes No
Composer wikimedia-au/link-cards
License GNU General Public License 3.0 or later
Download
Quarterly downloads 2 (Ranked 131st)
Translate the LinkCards extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The LinkCards extension adds two parser functions for the easy display of grids of clickable image-and-title 'cards'. Cards are graphical layout components that have an image, title, and some body text. Their entire area is a clickable link. The name comes from Bootstrap's version of this idea, from which we're borrowing.

Cards can be displayed singularly, or with multiple on one line. On small screens they are reduced to either full width (for a single card or more than two) or two cards side-by-side (if there are only two).

The images in cards are always the same height, so that the card titles always line up horizontally. This means that images will be cropped if their aspect ratio is not correct.

This extension doesn't really do anything that's not also possible via on-wiki templates and styles, it's just easier to deploy to multiple wikis.

Installation

[edit]
  • Download and move the extracted LinkCards folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LinkCards
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'LinkCards' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

[edit]

A single card:

{{#linkcard:Link|title=Lorem Ipsum|body=Lorem ipsum sic non muelo sarcinam portat.}}
{{#linkcard: Link pagename here
 | title = Lorem Ipsum
 | body  = Lorem ipsum sic non muelo sarcinam portat.
 | image = Example.jpg
}}

Multiple cards on one line:

{{#linkcards:

 | link1  = Link One
 | title1 = Title One
 | body1  = Body one.
 | image1 = Example.png

 | link2  = Link Two
 | title2 = Title Two
 | body2  = Body two.
 | image2 = Example2.png

}}

To show multiple cards over multiple lines, use the |perrow= parameter (similar in function to the parameter of the same name for the built-in gallery syntax), e.g.:

{{#linkcards:
 | perrow = 4
 | link1  = Link One
 | title1 = Title One
 | body1  = Body one.
 | image1 = Example.png
 …
 | link10  = Link Ten
 | title10 = Title Ten
 | body10  = Body ten.
 | image10 = Example10.png
}}

Reference

[edit]

The parameters to both {{#linkcard:}} and {{#linkcards:}} are as follows:

Parameter Type Description
|perrow= Integer How many cards to show per row; without this they will all be on one line.
|link= Page title The target of the link for the card.
|title= Text Title to display.
|body= Text The wikitext to show for the body.
|image= Filename Name of the file to show, without the 'File:' prefix.
|image-width= Integer Width in pixels of the displayed image. This does not change the actual displayed width, as that's set by the column width (in the case of top/bottom images) or to a set amount (for the start/end images). Rather, this is used to select which thumbnail of an image to use. Default is 800 (not there are no units needed for this value, it is always in pixels).
|image-position= String Side on which to display the image within the card. One of 'top', 'end', 'bottom', or 'start'. Defaults to 'top'.
|image-offset-dir= String Direction in which to offset the image within its frame. One of 'top', 'left', 'bottom', or 'right'.
|image-offset-val= Integer Percentage by which the image should be offset, between -100 and 100.