Jump to content

Extension:LinkCards

From mediawiki.org
MediaWiki extensions manual
LinkCards
Release status: experimental
Implementation Parser function
Author(s) Sam Wilson (Samwilsontalk)
Latest version 0.4.0 (2022-08-11)
MediaWiki >= 1.35.0
Database changes No
Composer wikimedia-au/link-cards
License GNU General Public License 3.0 or later
Download
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.}}

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
}}