Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:InfoboxImage

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
WarningThis Lua module is used in system messages, and onapproximately 5,230,000 pages, or roughly 8% of all pages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on thetalk page before implementing them.
Thismodule is rated asready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned onhelp pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed throughsandbox testing rather than repeated trial-and-error editing.
Page protectedThis module is currentlyprotected from editing.
See theprotection policy andprotection log for more details. Please discuss any changes on thetalk page; you maysubmit an edit request to ask anadministrator to make an edit if it isuncontroversial or supported byconsensus. You may alsorequest that this page be unprotected.
This module depends on the following other modules:
For guide on extended image syntax used in wikitext, seeWikipedia:Extended image syntax.

Overview

This module is used within infoboxes to process the image parameters and tidy up the formatting of the result.

Parameters

ParameterDescription
imageRequired. The main parameter that should be passed over which contains the image info.
sizeSize to display image, in pixels. Use is discouraged perWP:THUMBSIZE; see|upright= below instead.
maxsizeMaximum size to display image. Note: If no size or sizedefault params specified then image will be shown at maxsize.
sizedefaultThe size to use for the image if no size param is specified. Defaults toframeless.
altAlt text for the image.
titleTitle text for image (mouseover text).
borderIf yes, then a border is added.
pageThe page number to be displayed when using a multi-page image.
uprightIf upright=yes, adds "upright" which displays image at 75% of default image size (which is 250px if not changed atSpecial:Preferences). If a value, adds "upright=value" to image, where values less than 1 scale the image down (0.9 = 90%) and values greater than 1 scale the image up (1.15 = 115%).
centerIf yes, then the image is centered.
thumbtimethumbtime param, used for video clips.
suppressplaceholderIf no, then will not suppress certain placeholder images. See§ Placeholder images which can be suppressed.
linkPage to go to when clicking on the image.
classHTML classes to add to the image.

Note: If you specify the maxsize or sizedefault params, then you should include the px after the number.

Parameters displayed in image syntax

All parameters:

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}| size={{{size}}}| maxsize={{{maxsize}}}| sizedefault={{{sizedefault}}}| upright={{{upright}}}| alt={{{alt}}}| title={{{title}}}| thumbtime={{{thumbtime}}}| link={{{link}}}| border=yes| center=yes| page={{{page}}}| class={{{class}}}}}
[[File:{{{image}}}|page={{{page}}}|{{{size}}}|center|alt={{{alt}}}|link={{{link}}}|border|upright={{{upright}}}|thumbtime={{{thumbtime}}}|class={{{class}}}|{{{title}}}]]

When "size" and "maxsize" are defined, the smaller of the two is used (if "px" is omitted it will be added by the module):

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}| size=300px| maxsize=250px}}
[[File:{{{image}}}|250px]]

When "size" is not defined, "sizedefault" is used, even if larger than "maxsize" (in actual use "px" is required after the number; omitted here to show it is not added by the module):

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}| sizedefault=250px| maxsize=200px}}
[[File:{{{image}}}|250px]]

When "size" and "sizedefault" are not defined, "maxsize" is used (in actual use "px" is required after the number; omitted here to show it is not added by the module):

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}| maxsize=256px}}
[[File:{{{image}}}|256px]]

When "size", "sizedefault", and "maxsize" are not defined, "frameless" is added, which displays the image at the default thumbnail size (250px, but logged in users can change this atSpecial:Preferences) and is required if using "upright" to scale the default size:

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}}}
[[File:{{{image}}}|frameless]]

Use of "upright" without a number value, which displays the image at approximately 75% of the user's default size (multiplied by 0.75 then rounded to nearest 10):

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}| upright= yes}}
[[File:{{{image}}}|frameless|upright]]

When "alt" is used without "title", the alt text is also used as the title:

{{#invoke:InfoboxImage| InfoboxImage| image={{{image}}}| alt= Alt text}}
[[File:{{{image}}}|frameless|alt=Alt text]]

For more information, seeWikipedia:Extended image syntax.

Sample usage

|image ={{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}|upright={{{image_upright|1}}}|alt={{{alt|}}}}}

Examples

{{#invoke:InfoboxImage|InfoboxImage}}
{{#invoke:InfoboxImage|InfoboxImage|image=}}

{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg}}
{{#invoke:InfoboxImage|InfoboxImage|image=File:Abbey Rd Studios.jpg}}
{{#invoke:InfoboxImage|InfoboxImage|image=Image:Abbey Rd Studios.jpg}}

{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|upright=yes}}

{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|upright=1.2}}

{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|size=100px}}
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|size=100}}

{{#invoke:InfoboxImage|InfoboxImage|image=[[File:Abbey Rd Studios.jpg|200px]]}}
{{#invoke:InfoboxImage|InfoboxImage|image=[[File:Abbey Rd Studios.jpg|200px]]|title=Abbey Road!}}
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|sizedefault=250px|alt=The front stairs and door of Abbey Road Studios}}The front stairs and door of Abbey Road Studios
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|sizedefault=250|alt=The front stairs and door of Abbey Road Studios}}The front stairs and door of Abbey Road Studios
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|sizedefault=250px|alt=The front stairs and door of Abbey Road Studios|title=Exterior, front view of Abbey Road studios}}The front stairs and door of Abbey Road Studios
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|alt=The front stairs and door of Abbey Road Studios}}The front stairs and door of Abbey Road Studios
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|size=100px|alt=The front stairs and door of Abbey Road Studios}}The front stairs and door of Abbey Road Studios
{{#invoke:InfoboxImage|InfoboxImage|image=Bandera de Bilbao.svg|size=100|border=yes}}
{{#invoke:InfoboxImage|InfoboxImage|image=Image is needed male.svg}}
{{#invoke:InfoboxImage|InfoboxImage|image=Image is needed male.svg|suppressplaceholder=no}}
{{#invoke:InfoboxImage|InfoboxImage|image=[[File:Image is needed male.svg|200px]]}}
{{#invoke:InfoboxImage|InfoboxImage|image=[[File:Image is needed male.svg|200px]]|suppressplaceholder=no}}
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|size=50px|maxsize=100px}}
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|size=200px|maxsize=100px}}
{{#invoke:InfoboxImage|InfoboxImage|image=[[File:Abbey Rd Studios.jpg|200px]]|maxsize=100px}}
{{#invoke:InfoboxImage|InfoboxImage|image=Abbey Rd Studios.jpg|maxsize=100px|center=yes}}
{{#invoke:InfoboxImage|InfoboxImage|image=no such image|maxsize=100px|center=yes}}
File:No such image
{{#invoke:InfoboxImage|InfoboxImage|image={{Multiple image|width=50|image1=Yellow card.svg|image2=Red card.svg}}}}

Placeholder images which can be suppressed

Tracking categories

The abovedocumentation istranscluded fromModule:InfoboxImage/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) andtestcases(edit |run) pages.
Subpages of this module.

-- Inputs:--    image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link--    page - page to display for multipage images (DjVu)--    size - size to display the image--    maxsize - maximum size for image--    sizedefault - default size to display the image if size param is blank--    alt - alt text for image--    title - title text for image--    border - set to yes if border--    center - set to yes, if the image has to be centered--    upright - upright image param--    suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it--    link - page to visit when clicking on image--    class - HTML classes to add to the image-- Outputs:--    Formatted image.-- More details available at the "Module:InfoboxImage/doc" pagelocali={}-- List of placeholder images and tracking categories stored in [[Module:InfoboxImage/data]]-- Other constants:--   the system-wide default thumbnail size (in px)localdefaultThumbnailSize=250-- If page is not a user page, return tracking category. Else return empty.localfunctiontrackingCat(cat)localns=mw.title.getCurrentTitle().nsText:lower()localcategories=mw.loadData('Module:InfoboxImage/data').categoriesreturn(ns~='user'andns~='user talk'andcategories[cat])or""end-- Determine whether image is a placeholderfunctioni.IsPlaceholder(image)-- change underscores to spacesimage=mw.ustring.gsub(image,"_"," ");assert(image~=nil,'mw.ustring.gsub(image, "_", " ") must not return nil')-- if image starts with [[ then remove that and anything after |ifmw.ustring.sub(image,1,2)=="[["thenimage=mw.ustring.sub(image,3);image=mw.ustring.gsub(image,"([^|]*)|.*","%1");assert(image~=nil,'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil')end-- Trim spacesimage=mw.ustring.gsub(image,'^[ ]*(.-)[ ]*$','%1');assert(image~=nil,"mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil")-- remove prefix if existslocalallNames=mw.site.namespaces[6].aliasesallNames[#allNames+1]=mw.site.namespaces[6].nameallNames[#allNames+1]=mw.site.namespaces[6].canonicalNamefori,nameinipairs(allNames)doifmw.ustring.lower(mw.ustring.sub(image,1,mw.ustring.len(name)+1))==mw.ustring.lower(name..":")thenimage=mw.ustring.sub(image,mw.ustring.len(name)+2);breakendend-- Trim spacesimage=mw.ustring.gsub(image,'^[ ]*(.-)[ ]*$','%1');-- capitalise first letterimage=mw.ustring.upper(mw.ustring.sub(image,1,1))..mw.ustring.sub(image,2);localplaceholder_image=mw.loadData('Module:InfoboxImage/data').placeholder_imagereturnplaceholder_image[image]endlocalfunctionisempty(x)return(notx)orx==""end-- Main entry pointfunctioni.InfoboxImage(frame)localimage=frame.args["image"];ifisempty(image)thenreturn"";endifimage=="&nbsp;"thenreturnimage;endifframe.args["suppressplaceholder"]~="no"thenifi.IsPlaceholder(image)==truethenreturn"";endendifstring.find(image,"^%[*https?:")then-- Error category.returntrackingCat("url_image_links")endifmw.ustring.sub(image,1,2)=="[["then-- search for thumbnail images and add to tracking cat if foundlocalcat="";ifmw.title.getCurrentTitle().namespace==0and(mw.ustring.find(image,"|%s*thumb%s*[|%]]")ormw.ustring.find(image,"|%s*thumbnail%s*[|%]]"))thencat=trackingCat("thumbnail_images")endreturnimage..cat;elseifmw.ustring.sub(image,1,2)=="{{"andmw.ustring.sub(image,1,3)~="{{{"thenreturnimage;elseifmw.ustring.sub(image,1,1)=="<"thenreturnimage;elseifmw.ustring.sub(image,1,8)==mw.ustring.char(127).."'\"`UNIQ"then-- Found strip marker at begining, so pass don't process at allreturnimage;elselocalresult="";localpage=frame.args["page"];localupright=frame.args["upright"]or""localsize=frame.args["size"];localmaxsize=frame.args["maxsize"];localsizedefault=frame.args["sizedefault"];localalt=frame.args["alt"];locallink=frame.args["link"];localtitle=frame.args["title"];localborder=frame.args["border"];localthumbtime=frame.args["thumbtime"]or"";localcenter=frame.args["center"];localclass=frame.args["class"];-- remove prefix if existslocalallNames=mw.site.namespaces[6].aliasesallNames[#allNames+1]=mw.site.namespaces[6].nameallNames[#allNames+1]=mw.site.namespaces[6].canonicalNamefori,nameinipairs(allNames)doifmw.ustring.lower(mw.ustring.sub(image,1,mw.ustring.len(name)+1))==mw.ustring.lower(name..":")thenimage=mw.ustring.sub(image,mw.ustring.len(name)+2);breakendendifnotisempty(maxsize)then-- if no sizedefault nor upright, then set to maxsizeifisempty(sizedefault)andisempty(upright)thensizedefault=maxsizeend-- check to see if size bigger than maxsizelocalmaxsizenumber=tonumber(mw.ustring.match(maxsize,"%d*"))or0;ifnotisempty(size)thenlocalsizenumber=tonumber(mw.ustring.match(size,"%d*"))or0;ifsizenumber>maxsizenumberandmaxsizenumber>0thensize=maxsize;endend-- check to see if upright bigger than maxsize (at default preferred size)ifnotisempty(upright)thenlocaluprightnumber=tonumber(upright)or(upright=="yes"and0.75)or0ifuprightnumber*defaultThumbnailSize>maxsizenumberandmaxsizenumber>0thenupright=tostring(maxsizenumber/defaultThumbnailSize)endendend-- add px to size if just a numberif(tonumber(size)or0)>0thensize=size.."px";end-- add px to sizedefault if just a numberif(tonumber(sizedefault)or0)>0thensizedefault=sizedefault.."px";endresult="[[File:"..image;ifnotisempty(page)thenresult=result.."|page="..page;endifnotisempty(size)thenresult=result.."|"..size;elseifnotisempty(sizedefault)andisempty(upright)thenresult=result.."|"..sizedefault;elseresult=result.."|frameless";endifcenter=="yes"thenresult=result.."|center"endifnotisempty(alt)thenresult=result.."|alt="..alt;endifnotisempty(link)thenresult=result.."|link="..link;endifborder=="yes"thenresult=result.."|border";endifupright=="yes"thenresult=result.."|upright";elseifupright~=""thenresult=result.."|upright="..upright;endifthumbtime~=""thenresult=result.."|thumbtime="..thumbtime;endifnotisempty(class)thenresult=result.."|class="..class;end-- if alt value is a keyword then do not use as a descriptionifalt=="thumbnail"oralt=="thumb"oralt=="frameless"oralt=="left"oralt=="center"oralt=="right"oralt=="upright"oralt=="border"ormw.ustring.match(altor"",'^[0-9]*px$',1)~=nilthenalt=nil;endifnotisempty(title)then-- does title param contain any templatestyles? If yes then set to blank.ifmw.ustring.match(frame:preprocess(title),'UNIQ%-%-templatestyles',1)~=nilthentitle=nil;endendifnotisempty(title)thenresult=result.."|"..title;endresult=result.."]]";returnresult;endendreturni;
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:InfoboxImage&oldid=1317484358"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp