Template:Clean image

From RuneRealm Wiki

This is the current revision of this page, as edited by Alex (talk | contribs) at 23:13, 15 October 2024 (Created page with "{{#invoke:clean image|main}}<noinclude>{{/doc}}</noinclude>"). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Template documentation
This documentation is transcluded from Template:Clean image/doc. [edit] [history] [purge]
Template:Clean image invokes function main in Module:Clean image using Lua.
Template:Clean image invokes Module:clean image using Lua.

Cleans and formats an input image. This removes the following things if present:

  • [[File:
  • ]]
  • | and {{!}}, and everything following the first of these until the end

Then it re-packages the image into a new file container, with specified height, width, and link.

Usage

{{clean image
|file = wikitext to be cleaned; this should usually be a template parameter (e.g. |file={{{image}}}); required
|width = width of image; no default; exclude 'px'
|height = height of image; no default; exclude 'px'; can be combined with width
|link = link to apply to image; no default (will link to file page); setting to no will suppress normal link
}}

Examples

To be practical the results will be as if |image=[[File:Weird gloop.png|100px|link=abyssal whip]] as the input.

Example Code Result Notes
Just clean
{{clean image|file={{{image}}}}}
Should result in
[[File:{FILENAME}]]

Note that it links to the file page as a normal image does.

Clean + width
{{clean image|file={{{image}}}|width=50}}
Should result in
[[File:{FILENAME}|{WIDTH}px]]
Clean + height
{{clean image|file={{{image}}}|height=20}}
Should result in
[[File:{FILENAME}|x{HEIGHT}px]]

Remember that height parameters on images are maximum height limits and won't make an image bigger (without a width set).

Clean + width + height
{{clean image|file={{{image}}}|width=44|height=20}}
{{clean image|file={{{image}}}|width=11|height=50}}
{{clean image|file={{{image}}}|width=66|height=66}}



Should result in
[[File:{FILENAME}|{WIDTH}x{HEIGHT}px]]

Remember that height is still a maximum limit here. The size will be {WIDTH}px wide unless this makes the height more than {HEIGHT}px, in which case it is sized down to {HEIGHT}px tall. Aspect ratio is always kept.

Weird gloop.png is 22px wide and 30px tall. In the first use it is trying to resize to twice as wide but the maximum height of 20px forces it to resize down to 15x20px. The second use it successfully resizes down to half as wide, 11x15px. The third use is trying to go thrice as wide but the height limit only allows it to go twice as tall, so is 44x60px.

Clean + link
{{clean image|file={{{image}}}|link=Weird gloop}}
Should result in
[[File:{FILENAME}|link={LINK}]]
Clean + link suppress
{{clean image|file={{{image}}}|link=no}}
Should result in
[[File:{FILENAME}|link=]]