Difference between revisions of "Template:Quality/doc"

From Stardew Valley Wiki
Jump to navigation Jump to search
m (update docs, examples)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This template displays an image with a superimposed quality star, i.e., a star colored to match the item's quality (Silver, Gold, Iridium).
+
==Description==
 +
This template overlays a quality star icon (silver, gold, or iridium) over an image.  
  
==Usage==
+
==Parameters==
===Syntax===
+
{|class="wikitable"
Basic usage:
+
|-
<nowiki>{{</nowiki>'''Quality'''|''item_name''|''quality''<nowiki>}}</nowiki>
+
!Parameter
 
+
!Notes
Complete argument list:
+
|-
<nowiki>{{</nowiki>'''Quality'''|''item_name''|''quality''| size=''px'' | link=''link'' | alt=''alt'' <nowiki>}}</nowiki>
+
|First (unnamed) parameter
 
+
|Name of background image (without extension such as .png)
===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.
+
|Second (unnamed) parameter
 
+
|Quality star to display<br />Valid values: normal, 0, silver, 1, gold, 2, iridium, 4
* '''''item_name'''''
+
|-
** First unnamed parameter, required
+
|Third (unnamed) parameter
** The name of an item, or more specifically the name of the image (without .png)
+
|Desired display width of background image (do not include "px")<br />Valid values: 48, 36, 32, 24 (other values will be accepted, but may produce undesired results)<br />Default value: 24
** 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, <tt>Blank_Icon</tt>, solely to make the template not generate errors in the default display on other languages.
+
|Fourth (unnamed) parameter
** 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.
+
|<samp>center</samp>, if the image is to be displayed in a table cell. Adding this parameter will center the image in the cell.
 
+
|-
* '''''quality'''''
+
|}
** Second unnamed parameter, required
 
** Possible values are <tt>Silver</tt>, <tt>Gold</tt>, <tt>Iridium</tt>. 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 <tt>24</tt>, <tt>32</tt>, and <tt>48</tt>.  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").<ref name="px">Technically, the template will strip any extra "px" from a provided size, but this usage is not recommended.</ref>
 
** For backwards compatibility, the size can also be provided as a third unnamed argument (e.g., <tt><nowiki>{{Quality|Parsnip|Silver|24}}</nowiki></tt>).
 
 
 
* '''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 (<tt>|link=|</tt>) 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 (<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>
+
{|class="wikitable"
Result: {{Quality|Parsnip|silver}}
+
|-
<pre>{{Quality|Kale|Gold|32|link=Vegetables}}</pre>
+
!Template Call
Result: {{Quality|Kale|Gold|32|link=Vegetables}}
+
!Result
<pre>{{Quality|Potato|size=32|link=}}</pre>
+
|-
Result: {{Quality|Potato|size=32|link=}}
+
|<code><nowiki>{{Quality|Parsnip|iridium}}</nowiki></code>
<pre>{{Quality|Milk|iridium|size=24|link=|alt=}}</pre>
+
|{{Quality|Parsnip|iridium}}
Result: {{Quality|Milk|iridium|size=24|link=|alt=}}
+
|-
 
+
|<code><nowiki>{{Quality|Parsnip|silver|24|center}}</nowiki></code>
==Technical Details==
+
|{{Quality|Parsnip|silver|24|center}}
<references>
+
|-
</references>
+
|<code><nowiki>{{Quality|Sunfish|normal|36}}</nowiki></code>
 
+
|{{Quality|Sunfish|normal|36}}
<includeonly>[[Category:Formatting templates]]</includeonly><noinclude>[[Category:Template documentation]]</noinclude>
+
|-
 +
|<code><nowiki>{{Quality|Red Plate|gold|36|center}}</nowiki></code>
 +
|{{Quality|Red Plate|gold|36|center}}
 +
|-
 +
|<code><nowiki>{{Quality|Beer|gold|48}}</nowiki></code>
 +
|{{Quality|Beer|gold|48}}
 +
|-
 +
|<code><nowiki>{{Quality|Large Goat Milk ES|gold|32|center}}</nowiki></code>
 +
|{{Quality|Large Goat Milk ES|gold|32|center}}
 +
|-
 +
|}<includeonly>{{Addlanglinks}}[[Category:Templates]]</includeonly><noinclude>[[Category:Template documentation]]</noinclude>

Latest revision as of 04:05, 14 February 2023

Description

This template overlays a quality star icon (silver, gold, or iridium) over an image.

Parameters

Parameter Notes
First (unnamed) parameter Name of background image (without extension such as .png)
Second (unnamed) parameter Quality star to display
Valid values: normal, 0, silver, 1, gold, 2, iridium, 4
Third (unnamed) parameter Desired display width of background image (do not include "px")
Valid values: 48, 36, 32, 24 (other values will be accepted, but may produce undesired results)
Default value: 24
Fourth (unnamed) parameter center, if the image is to be displayed in a table cell. Adding this parameter will center the image in the cell.

Examples

Template Call Result
{{Quality|Parsnip|iridium}}
Parsnip.png
Iridium Quality Icon.png
{{Quality|Parsnip|silver|24|center}}
Parsnip.png
Silver Quality Icon.png
{{Quality|Sunfish|normal|36}}
Sunfish.png
{{Quality|Red Plate|gold|36|center}}
Red Plate.png
Gold Quality Icon.png
{{Quality|Beer|gold|48}}
Beer.png
Gold Quality Icon.png
{{Quality|Large Goat Milk ES|gold|32|center}}
Large Goat Milk ES.png
Gold Quality Icon.png