Module:Image array
- العربية
- অসমীয়া
- Azərbaycanca
- Башҡортса
- Basa Bali
- Беларуская (тарашкевіца)
- Беларуская
- भोजपुरी
- বাংলা
- Bosanski
- Нохчийн
- Chamoru
- کوردی
- Чӑвашла
- Zazaki
- Ελληνικά
- English
- فارسی
- Suomi
- Føroyskt
- Galego
- ગુજરાતી
- हिन्दी
- Magyar
- Հայերեն
- Bahasa Indonesia
- ГӀалгӀай
- 日本語
- Jawa
- ქართული
- Қазақша
- ಕನ್ನಡ
- 한국어
- Kurdî
- Latviešu
- मैथिली
- Македонски
- മലയാളം
- Bahasa Melayu
- မြန်မာဘာသာ
- Norsk bokmål
- ଓଡ଼ିଆ
- پښتو
- Português
- Română
- Русский
- Scots
- တႆး
- සිංහල
- Simple English
- Српски / srpski
- Тоҷикӣ
- ไทย
- Türkçe
- Українська
- اردو
- Tiếng Việt
- 粵語
- 中文
Appearance
From Meta, a Wikimedia project coordination wiki
This module implements Template:Image array.
The above documentation is transcluded from Module:Image array/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
-- implements [[template:image array]] localp={} localfunctionisnotempty(s) returnsands:match('^%s*(.-)%s*$')~='' end localfunctionrenderArrayCell(img,c,a,b,l,tc,t,w,h) localalt=isnotempty(a)and('|alt='..a)or'' locallink=isnotempty(l)and('|link='..l)or'' localtext=(isnotempty(tc)andnotisnotempty(t)) andmw.text.unstrip(c)ormw.text.unstrip(tor'') localborder=isnotempty(b)and'|border'or'' localcell=mw.html.create('') if(img)then cell:tag('div') :css('display','table-cell') :css('vertical-align','middle') :css('width',w..'px') :css('height',h..'px') :css('margin-left','auto') :css('margin-right','auto') :wikitext(mw.ustring.format('[[File:%s|%dx%dpx%s|%s]]', img,w,h,alt..link..border,text)) cell:tag('div') :css('padding','1px') :wikitext(c) end returntostring(cell) end localfunctionimagearray(frame) localargs=frame:getParent().args localwidth=tonumber(args['width']or'60') localheight=tonumber(args['height']or'70') localperrow=tonumber(args['perrow']or'4') localbw=tonumber(args['border-width']or'0') localfs=args['font-size']or'88%' localtext=args['text']or'' localmargin=args['margin']or'auto' localborder=(bw>0)andtostring(bw)..'px #aaa solid'ornil -- find all the nonempty image numbers localimagenums={} localimagecount=0 fork,vinpairs(args)do locali=tonumber(tostring(k):match('^%s*image([%d]+)%s*$')or'0') if(i>0andisnotempty(v))then table.insert(imagenums,i) imagecount=imagecount+1 end end -- sort the image numbers table.sort(imagenums) -- compute the number of rows localrowcount=math.ceil(imagecount/perrow) -- if rowcount < 1 then -- return '[[Category:Pages using image array with no images]]' -- end -- start table root=mw.html.create('table') root :addClass(args['class']) :css('border-collapse','collapse') :css('text-align','center') :css('font-size',fs) :css('line-height','1.25em') :css('margin',margin) :css('width',tostring(width*perrow)..'px') -- loop over the images forj=1,rowcountdo localrow=root:tag('tr') row:css('vertical-align','top') fork=1,perrowdo i=imagenums[(j-1)*perrow+k]or0 row:tag('td') :css('width',width..'px') :css('text-align','center') :css(borderand'border'or'',borderor'') :wikitext(renderArrayCell( args['image'..i],args['caption'..i],args['alt'..i], args['border'..i],args['link'..i], args['text'],args['text'..i],width,height) ) end end -- end table returntostring(root) end functionp.array(frame) returnimagearray(frame) end returnp