Difference between revisions of "Template:Quality/doc"

From Stardew Valley Wiki
Jump to navigation Jump to search
(Note about Milk icons)
m (update docs, examples)
Line 31: Line 31:
  
 
* '''link=''link'''''
 
* '''link=''link'''''
** Name of page (without square brackets) that item icon should link to. By default empty, meaning clicking on the icon does nothing.
+
** Name of page (without square brackets) that item icon should link to.
 +
** By default, link is automatically set to ''item_name''.
 +
** Setting link to an empty value (<tt>|link=|</tt>) disables the image link (clicking on the item does nothing).
  
 
* '''alt=''alt'''''
 
* '''alt=''alt'''''
** Alt text for item icon. Default value is ''link'' (if non-empty) or ''item_name''.
+
** Alt text for item icon. Default value is ''link'' or ''item_name''.
 
** This is not normally directly displayed on the page, but may be used by screen readers or accessibility-aware browsers.
 
** This is not normally directly displayed on the page, but may be used by screen readers or accessibility-aware browsers.
 +
** Setting alt to an empty value (<tt>|alt=|</tt>) disables the alt text.  Appropriate whenever image is immediately followed by item name to prevent name from being read twice in a row.
  
 
==Examples==
 
==Examples==
 
<pre>{{Quality|Parsnip|silver}}</pre>
 
<pre>{{Quality|Parsnip|silver}}</pre>
 
Result: {{Quality|Parsnip|silver}}
 
Result: {{Quality|Parsnip|silver}}
<pre>{{Quality|Kale|Gold|32}}</pre>
+
<pre>{{Quality|Kale|Gold|32|link=Vegetables}}</pre>
Result: {{Quality|Kale|Gold|32}}
+
Result: {{Quality|Kale|Gold|32|link=Vegetables}}
<pre>{{Quality|Potato|size=32|alt=Potato}}</pre>
+
<pre>{{Quality|Potato|size=32|link=}}</pre>
{{Quality|Potato|size=32|alt=Potato}}
+
Result: {{Quality|Potato|size=32|link=}}
<pre>{{Quality|Milk|iridium|size=24|link=Milk}}</pre>
+
<pre>{{Quality|Milk|iridium|size=24|link=|alt=}}</pre>
{{Quality|Milk|iridium|size=24|link=Milk}}
+
Result: {{Quality|Milk|iridium|size=24|link=|alt=}}
  
 
==Technical Details==
 
==Technical Details==

Revision as of 18:02, 24 September 2020

This template displays an image with a superimposed quality star, i.e., a star colored to match the item's quality (Silver, Gold, Iridium).

Usage

Syntax

Basic usage:

{{Quality|item_name|quality}}

Complete argument list:

{{Quality|item_name|quality| size=px | link=link | alt=alt }}

Parameters

There are two unnamed, required parameters, item_name and quality'. All other parameters are named and optional. Default value for all arguments is empty, unless specified otherwise.

  • item_name
    • First unnamed parameter, required
    • The name of an item, or more specifically the name of the image (without .png)
    • Note that there must be no spaces following the item_name -- the "|" symbol must come immediately afterwards, or the template will fail (due to quirks of how mediawiki templates process arguments)
    • There is technically a default value, Blank_Icon, solely to make the template not generate errors in the default display on other languages.
    • The template will automatically handle certain language-specific images. Namely in French, Japanese, Spanish, and Portuguese, all 4 Milk icons will be replaced with language-appropriate ones (where the "M" for cow milk or "G" for goat milk are replaced with more appropriate letters). The coding intentionally avoids using the expensive ifexist parser function because this template is frequently used dozens of times on a page. As a result, only specific known cases are recognized.
  • quality
    • Second unnamed parameter, required
    • Possible values are Silver, Gold, Iridium. Not case-sensitive. All other values are ignored (i.e., no star is displayed). If missing, no star is displayed.
    • On other languages, the translated terms are also recognized.
  • size=px
    • Size of icons in pixels. Default value is 24.
    • Standard values are 24, 32, and 48. Other values will work, but the size of the overlay region is always one of the standard values (e.g., there may be extra white space around the image).
    • Only the number should be provided (do not append "px").[1]
    • For backwards compatibility, the size can also be provided as a third unnamed argument (e.g., {{Quality|Parsnip|Silver|24}}).
  • link=link
    • Name of page (without square brackets) that item icon should link to.
    • By default, link is automatically set to item_name.
    • Setting link to an empty value (|link=|) disables the image link (clicking on the item does nothing).
  • alt=alt
    • Alt text for item icon. Default value is link or item_name.
    • This is not normally directly displayed on the page, but may be used by screen readers or accessibility-aware browsers.
    • Setting alt to an empty value (|alt=|) disables the alt text. Appropriate whenever image is immediately followed by item name to prevent name from being read twice in a row.

Examples

{{Quality|Parsnip|silver}}

Result:

Parsnip.png
Silver Quality Icon.png
{{Quality|Kale|Gold|32|link=Vegetables}}

Result:

Kale.png
Gold Quality Icon.png
{{Quality|Potato|size=32|link=}}

Result:

Potato.png
{{Quality|Milk|iridium|size=24|link=|alt=}}

Result:

Milk.png
Iridium Quality Icon.png

Technical Details

  1. Technically, the template will strip any extra "px" from a provided size, but this usage is not recommended.