<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://chaldeanwiki.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultiple_image</id>
		<title>Module:Multiple image - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://chaldeanwiki.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultiple_image"/>
		<link rel="alternate" type="text/html" href="https://chaldeanwiki.com/index.php?title=Module:Multiple_image&amp;action=history"/>
		<updated>2026-04-30T13:54:18Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.0</generator>

	<entry>
		<id>https://chaldeanwiki.com/index.php?title=Module:Multiple_image&amp;diff=1348&amp;oldid=prev</id>
		<title>Edokter: Add classes to enable interaction with gadgets and other scripts</title>
		<link rel="alternate" type="text/html" href="https://chaldeanwiki.com/index.php?title=Module:Multiple_image&amp;diff=1348&amp;oldid=prev"/>
				<updated>2015-02-13T17:00:16Z</updated>
		
		<summary type="html">&lt;p&gt;Add classes to enable interaction with gadgets and other scripts&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- implements [[template:multiple image]]&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function isnotempty(s)&lt;br /&gt;
	return s and s:match( '^%s*(.-)%s*$' ) ~= ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderImageCell(image, width, height, link, alt, caption, textalign) &lt;br /&gt;
	local root = mw.html.create('')&lt;br /&gt;
	&lt;br /&gt;
	local altstr = '|alt=' .. (alt or '')&lt;br /&gt;
	local linkstr = link and ('|link=' .. link) or ''&lt;br /&gt;
	local widthstr = '|' .. tostring(width) .. 'px'&lt;br /&gt;
	&lt;br /&gt;
	local imagediv = root:tag('div')&lt;br /&gt;
	imagediv:addClass('thumbimage')&lt;br /&gt;
	if( height ) then&lt;br /&gt;
		imagediv:css('height', tostring(height) .. 'px')&lt;br /&gt;
		imagediv:css('overflow', 'hidden')&lt;br /&gt;
	end&lt;br /&gt;
	imagediv:wikitext('[[file:' .. image .. widthstr .. linkstr .. altstr .. ']]')&lt;br /&gt;
	if isnotempty(caption) then&lt;br /&gt;
		local captiondiv = root:tag('div')&lt;br /&gt;
		captiondiv:addClass('thumbcaption')&lt;br /&gt;
		captiondiv:css('clear', 'left')&lt;br /&gt;
		if isnotempty(textalign) then&lt;br /&gt;
			captiondiv:css('text-align', textalign)&lt;br /&gt;
		end&lt;br /&gt;
		captiondiv:wikitext(caption)&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getWidth(w1, w2)&lt;br /&gt;
	local w&lt;br /&gt;
	if isnotempty(w1) then&lt;br /&gt;
		w = tonumber(w1)&lt;br /&gt;
	elseif isnotempty(w2) then&lt;br /&gt;
		w = tonumber(w2)&lt;br /&gt;
	end&lt;br /&gt;
	return w or 200&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderMultipleImages(frame)&lt;br /&gt;
	local pargs = frame:getParent().args&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	local width = pargs['width'] or ''&lt;br /&gt;
	local dir = pargs['direction'] or ''&lt;br /&gt;
	local align = pargs['align'] or args['align'] or ''&lt;br /&gt;
	local captionalign = pargs['caption_align'] or args['caption_align'] or ''&lt;br /&gt;
	local totalwidth = pargs['total_width'] or args['total_width'] or ''&lt;br /&gt;
	local height = nil&lt;br /&gt;
	local header = pargs['header'] or pargs['title'] or ''&lt;br /&gt;
	local footer = pargs['footer'] or ''&lt;br /&gt;
	local thumbclass = {&lt;br /&gt;
		[&amp;quot;left&amp;quot;] = 'tleft',&lt;br /&gt;
		[&amp;quot;none&amp;quot;] = 'tnone',&lt;br /&gt;
		[&amp;quot;center&amp;quot;] = 'tnone',&lt;br /&gt;
		[&amp;quot;centre&amp;quot;] = 'tnone',&lt;br /&gt;
		[&amp;quot;right&amp;quot;] = 'tright'&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	-- find all the nonempty images and corresponding widths&lt;br /&gt;
	-- also compute the sum of widths and maximum width&lt;br /&gt;
	local imagenumbers = {}&lt;br /&gt;
	local widths = {}&lt;br /&gt;
	local imagecount = 0&lt;br /&gt;
	local widthmax = 0&lt;br /&gt;
	local widthsum = 0&lt;br /&gt;
	for k, v in pairs( pargs ) do&lt;br /&gt;
		local i = tonumber(tostring(k):match( '^%s*image([%d]+)%s*$' ) or '0')&lt;br /&gt;
		if( i &amp;gt; 0 and isnotempty(v) ) then&lt;br /&gt;
			table.insert( imagenumbers, i)&lt;br /&gt;
			imagecount = imagecount + 1&lt;br /&gt;
			local w = getWidth(width, pargs['width' .. i])&lt;br /&gt;
			-- compute maximum width and width sum&lt;br /&gt;
			widthmax = math.max(widthmax, w)&lt;br /&gt;
			widthsum = widthsum + w&lt;br /&gt;
			-- store the modified width&lt;br /&gt;
			widths[i] = w&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- sort the imagenumbers&lt;br /&gt;
	table.sort(imagenumbers)&lt;br /&gt;
	&lt;br /&gt;
	-- if total_width has been specified, rescale the image widths&lt;br /&gt;
	if( isnotempty(totalwidth) ) then&lt;br /&gt;
		totalwidth = tonumber(totalwidth)&lt;br /&gt;
		if( dir == 'vertical' ) then&lt;br /&gt;
			width = totalwidth - 12&lt;br /&gt;
		else&lt;br /&gt;
			local tw = totalwidth - 4 * (imagecount - 1) - 12&lt;br /&gt;
			local ar = {}&lt;br /&gt;
			local arsum = 0&lt;br /&gt;
			for k=1,imagecount do&lt;br /&gt;
				local i = imagenumbers[k]&lt;br /&gt;
				local h = tonumber( pargs['height' .. i] or '' ) or 0&lt;br /&gt;
				if (h &amp;gt; 0) then&lt;br /&gt;
					ar[i] = widths[i]/h&lt;br /&gt;
					height = h&lt;br /&gt;
				else&lt;br /&gt;
					ar[i] = widths[i]/100&lt;br /&gt;
				end&lt;br /&gt;
				arsum = arsum + ar[i]&lt;br /&gt;
			end&lt;br /&gt;
			local ht = tw/arsum&lt;br /&gt;
			local ws = 0&lt;br /&gt;
			for k=1,imagecount do&lt;br /&gt;
				local i = imagenumbers[k]&lt;br /&gt;
				widths[i] = math.floor(ar[i]*ht + 0.5)&lt;br /&gt;
				ws = ws + widths[i]&lt;br /&gt;
			end&lt;br /&gt;
			widthsum = ws&lt;br /&gt;
			if height then&lt;br /&gt;
				height = math.floor(ht)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end	&lt;br /&gt;
&lt;br /&gt;
	-- start building the array of images, if there are images&lt;br /&gt;
	if( imagecount &amp;gt; 0 ) then&lt;br /&gt;
		local bodywidth = 0&lt;br /&gt;
		local bg = pargs['background color'] or ''&lt;br /&gt;
		-- create the array of images&lt;br /&gt;
		local root = mw.html.create('div')&lt;br /&gt;
		root:addClass('thumb')&lt;br /&gt;
		root:addClass('tmulti')&lt;br /&gt;
		root:addClass(thumbclass[align] or 'tright')&lt;br /&gt;
		if( dir == 'vertical') then&lt;br /&gt;
			bodywidth = widthmax + 12&lt;br /&gt;
		else&lt;br /&gt;
			bodywidth = widthsum + 4 * (imagecount - 1) + 12&lt;br /&gt;
		end&lt;br /&gt;
		if( align == 'center' or align == 'centre' ) then&lt;br /&gt;
			root:addClass('center')&lt;br /&gt;
		end&lt;br /&gt;
		if( pargs['margin_top'] or args['margin_top']) then&lt;br /&gt;
			root:css('margin-top', pargs['margin_top'] or args['margin_top'])&lt;br /&gt;
		end&lt;br /&gt;
		if( pargs['margin_bottom'] or args['margin_bottom']) then&lt;br /&gt;
			root:css('margin-bottom', pargs['margin_bottom'] or args['margin_bottom'])&lt;br /&gt;
		end&lt;br /&gt;
		if( bg ~= '' ) then&lt;br /&gt;
			root:css('background-color', bg)&lt;br /&gt;
		end&lt;br /&gt;
		-- The body has a min-width of 100, which needs to be taken into account on specific widths&lt;br /&gt;
		bodywidth = math.max( 100, bodywidth - 8);&lt;br /&gt;
		local div = root:tag('div')&lt;br /&gt;
		div:addClass('thumbinner')&lt;br /&gt;
		div:css('width', tostring(bodywidth) .. 'px')&lt;br /&gt;
			:css('max-width', tostring(bodywidth) .. 'px')&lt;br /&gt;
		if( bg ~= '' ) then&lt;br /&gt;
			div:css('background-color', bg)&lt;br /&gt;
		end&lt;br /&gt;
		-- add the header&lt;br /&gt;
		if( isnotempty(header) ) then&lt;br /&gt;
			div:tag('div')&lt;br /&gt;
				:css('clear', 'both')&lt;br /&gt;
				:css('font-weight', 'bold')&lt;br /&gt;
				:css('text-align', pargs['header_align'] or 'center')&lt;br /&gt;
				:css('background-color', pargs['header_background'] or 'transparent')&lt;br /&gt;
				:wikitext(header)&lt;br /&gt;
		end&lt;br /&gt;
		-- loop through the images&lt;br /&gt;
		for k=1,imagecount do&lt;br /&gt;
			local imagediv = div:tag('div')&lt;br /&gt;
			imagediv:addClass('tsingle')&lt;br /&gt;
			if dir ~= 'vertical' then&lt;br /&gt;
				imagediv:css('float', 'left')&lt;br /&gt;
			end&lt;br /&gt;
			if bg ~= '' then&lt;br /&gt;
				imagediv:css('background-color', bg);&lt;br /&gt;
			end&lt;br /&gt;
			imagediv:css('margin', '1px')&lt;br /&gt;
			local i = imagenumbers[k]&lt;br /&gt;
			local img = pargs['image' .. i]&lt;br /&gt;
			local w = widths[i]&lt;br /&gt;
			imagediv:css('width', tostring(2 + w) .. 'px')&lt;br /&gt;
				:css('max-width', tostring(2 + w) .. 'px')&lt;br /&gt;
			imagediv:wikitext(renderImageCell(img, w, height, &lt;br /&gt;
				pargs['link' .. i], pargs['alt' .. i], pargs['caption' .. i], captionalign))&lt;br /&gt;
		end&lt;br /&gt;
		-- only float content gives a parent height:0, so add a clearing div&lt;br /&gt;
		div:tag('div')&lt;br /&gt;
			:css('clear', 'left')&lt;br /&gt;
		-- add the footer&lt;br /&gt;
		if( isnotempty(footer) ) then&lt;br /&gt;
			div:tag('div')&lt;br /&gt;
				:addClass('thumbcaption')&lt;br /&gt;
				:css('clear', 'left')&lt;br /&gt;
				:css('text-align', pargs['footer_align'] or args['footer_align'] or 'left')&lt;br /&gt;
				:css('background-color', pargs['footer_background'] or 'transparent')&lt;br /&gt;
				:wikitext(footer)&lt;br /&gt;
		end&lt;br /&gt;
		return tostring(root)&lt;br /&gt;
	end&lt;br /&gt;
	return ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.render( frame )&lt;br /&gt;
    return renderMultipleImages( frame )&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Edokter</name></author>	</entry>

	</feed>