Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Gallery items
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- this module implements [[template:gallery items]] local p = {} function p.main(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame) local width = args.width or '150' local items = {} local itemnums = {} for k, v in pairs(args) do if k ~= nil and tonumber(k) and math.fmod(k,2) == 1 then local i = math.floor(k/2) + 1 table.insert( itemnums, i ) local item = mw.html.create('li') :addClass('gallerybox') :css('width', (args['width' .. k] or width)+5 .. 'px') local itemdiv = item:tag('div'):css('width', (args['width' .. k] or width)+5 .. 'px') itemdiv:tag('div') :addClass('thumb') :css('width', (args['width' .. k] or width) .. 'px') :css('text-align', args['itemalign']) :wikitext('<div style="margin:0px auto">' .. args[k] .. '</div>') if args[tonumber(k)+1] then itemdiv :tag('div') :addClass('gallerytext') :css('text-align', args['captionalign']) :wikitext('<p>' .. args[tonumber(k)+1] .. '</p>') end items[i] = tostring(item) .. ' ' end end -- remove blanks table.sort(itemnums) local sorteditems = {} for k = 1, #itemnums do sorteditems[k] = items[itemnums[k]] end local root = mw.html.create('ul') :addClass('gallery mw-gallery-nolines gallery-items') :addClass(args.class) :cssText(args.style) :wikitext(table.concat(sorteditems)) return frame:extensionTag {name = 'templatestyles', args = {src = 'Gallery items/styles.css'}} .. frame:extensionTag{ name = 'gallery', args = {mode = 'nolines'}} .. tostring(root) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Tl
(
edit
)
Module:Gallery items/doc
(
edit
)