Template:Article thumbnail: Difference between revisions
Appearance
Content deleted Content added
No edit summary Tag: Manual revert |
No edit summary |
||
| Line 4: | Line 4: | ||
[[File:{{{image|work-in-progress-book.jpg}}}|{{{width|180}}}px|link={{{page|{{BASEPAGENAME}}}}}|alt={{{alt|Thumbnail for {{{page|{{BASEPAGENAME}}}}}}}}]] |
[[File:{{{image|work-in-progress-book.jpg}}}|{{{width|180}}}px|link={{{page|{{BASEPAGENAME}}}}}|alt={{{alt|Thumbnail for {{{page|{{BASEPAGENAME}}}}}}}}]] |
||
</div> |
</div> |
||
<div class="article-thumb__caption" |
<div class="article-thumb__caption"> |
||
[[{{{page|{{BASEPAGENAME}}}}}]] |
|||
<div class="article-thumb__text">{{{caption|}}}</div> |
|||
| ⚫ | |||
</div><noinclude> |
</div><noinclude> |
||
== What this does == |
== What this does == |
||
Displays a small, consistent '''article thumbnail''' card: an image that links to a page, with a caption under it. |
Displays a small, consistent '''article thumbnail''' card: an image that links to a page, with a caption under it. |
||
This version performs '''no existence checks''' (no <code>#ifexist</code>) to avoid expensive parser calls. Styling is provided via TemplateStyles (''Article thumbnail/styles.css''). Images are centered and scaled to fit the fixed thumbnail area. |
|||
== Parameters == |
== Parameters == |
||
* <code>image</code> – Optional. File name |
* <code>image</code> – Optional. File name without <code>File:</code> prefix. |
||
| ⚫ | |||
If omitted, it defaults to <code>work-in-progress-book.jpg</code>. '''No existence check is performed'''—if the specified file does not exist, MediaWiki will render it as a missing image link/icon as per your wiki configuration. |
|||
* <code> |
* <code>caption</code> – Optional. Plain text description appearing under the page link. |
||
* <code>width</code> – Optional. |
* <code>width</code> – Optional. Numeric width for the file (defaults to 180). |
||
* <code>alt</code> – Optional. Accessibility text. |
|||
Note: The card itself is fixed at 150 px wide by CSS; the image is scaled to fit inside the 150×180 area. |
|||
| ⚫ | |||
== |
== Example == |
||
Basic (links to the current page): |
|||
<pre> |
<pre> |
||
{{Article thumbnail |
{{Article thumbnail |
||
| image = Atomic Habits cover.jpg |
| image = Atomic Habits cover.jpg |
||
| ⚫ | |||
| caption = James Clear (2018) |
|||
}} |
}} |
||
</pre> |
</pre> |
||
Link to a specific page: |
|||
<pre> |
|||
{{Article thumbnail |
|||
| image = Atomic Habits cover.jpg |
|||
| ⚫ | |||
}} |
|||
| ⚫ | |||
Custom image width (number only): |
|||
<pre> |
|||
{{Article thumbnail |
|||
| image = Atomic Habits cover.jpg |
|||
| width = 200 |
|||
}} |
|||
</pre> |
|||
Custom alt text: |
|||
<pre> |
|||
{{Article thumbnail |
|||
| image = Atomic Habits cover.jpg |
|||
| alt = Atomic Habits by James Clear, book cover |
|||
}} |
|||
</pre> |
|||
Two thumbnails side by side (inline cards): |
|||
<pre> |
|||
{{Article thumbnail |
|||
| image = Atomic Habits cover.jpg |
|||
| page = Atomic Habits |
|||
}} |
|||
{{Article thumbnail |
|||
| image = How to Win Friends.jpg |
|||
| page = How to Win Friends and Influence People |
|||
}} |
|||
</pre> |
|||
== Notes == |
|||
* Provide the exact file name, including extension, but do not include the <code>File:</code> prefix in <code>|image=</code>. |
|||
* This template intentionally avoids expensive parser functions. There is '''no automatic fallback''' if the file is missing; pass a known placeholder (e.g., <code>work-in-progress-book.jpg</code>) from the caller if you want a guaranteed image. |
|||
* The CSS fixes the card width (150 px) and image area height (180 px). The image is centered and constrained with <code>max-width:100%</code> and <code>max-height:100%</code>. |
|||
* For grid layouts, place multiple template calls on the same line or separated by spaces; each card is <code>display:inline-block</code> and will wrap as needed. |
|||
</noinclude> |
</noinclude> |
||
Revision as of 15:19, 4 January 2026
What this does
Displays a small, consistent article thumbnail card: an image that links to a page, with a caption under it.
Parameters
image– Optional. File name withoutFile:prefix.page– Optional. Target page for the link. Defaults toArticle thumbnail.caption– Optional. Plain text description appearing under the page link.width– Optional. Numeric width for the file (defaults to 180).alt– Optional. Accessibility text.
Example
{{Article thumbnail
| image = Atomic Habits cover.jpg
| page = Atomic Habits
| caption = James Clear (2018)
}}