<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://nationalatlas.ign.es/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="http://nationalatlas.ign.es/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultiple_image"/>
	<link rel="alternate" type="text/html" href="http://nationalatlas.ign.es/index.php?title=Module:Multiple_image&amp;action=history"/>
	<updated>2026-04-04T10:23:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>http://nationalatlas.ign.es/index.php?title=Module:Multiple_image&amp;diff=3508&amp;oldid=prev</id>
		<title>Ane: 1 revisión importada</title>
		<link rel="alternate" type="text/html" href="http://nationalatlas.ign.es/index.php?title=Module:Multiple_image&amp;diff=3508&amp;oldid=prev"/>
		<updated>2018-11-16T07:59:43Z</updated>

		<summary type="html">&lt;p&gt;1 revisión importada&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 autoscaledimages&lt;br /&gt;
local nonautoscaledimages&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 getdimensions(s, w, h)&lt;br /&gt;
	if tonumber(w) and tonumber(h) then&lt;br /&gt;
		nonautoscaledimages = true&lt;br /&gt;
		return tonumber(w), tonumber(h)&lt;br /&gt;
	end&lt;br /&gt;
	local file = s and mw.title.new('File:' .. mw.uri.decode(mw.ustring.gsub(s,'%|.*$',''), 'WIKI'))&lt;br /&gt;
	file = file and file.file or {width = 0, height = 0}&lt;br /&gt;
	w = tonumber(file.width) or 0&lt;br /&gt;
	h = tonumber(file.height) or 0&lt;br /&gt;
	autoscaledimages = true&lt;br /&gt;
	return w, h&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderImageCell(image, width, height, link, alt, thumbtime, caption, textalign, istyle)&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;
	local thumbtimestr = ''&lt;br /&gt;
&lt;br /&gt;
	if isnotempty( thumbtime ) then&lt;br /&gt;
		thumbtimestr = '|thumbtime=' .. thumbtime&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local imagediv = root:tag('div')&lt;br /&gt;
	imagediv:addClass('thumbimage')&lt;br /&gt;
	imagediv:cssText(istyle)&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 .. thumbtimestr .. ']]')&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 getPerRow(pstr, ic)&lt;br /&gt;
	-- split string into array using any non-digit as a dilimiter&lt;br /&gt;
	local pr = mw.text.split(pstr or '', '[^%d][^%d]*')&lt;br /&gt;
	-- if split failed, assume a single row&lt;br /&gt;
	if (#pr &amp;lt; 1) then&lt;br /&gt;
		pr = {tostring(ic)}&lt;br /&gt;
	end&lt;br /&gt;
	-- convert the array of strings to an array of numbers,&lt;br /&gt;
	-- adding any implied/missing numbers at the end of the array&lt;br /&gt;
	local r = 1&lt;br /&gt;
	local thisrow = tonumber(pr[1] or ic) or ic&lt;br /&gt;
	local prownum = {}&lt;br /&gt;
	while( ic &amp;gt; 0 ) do&lt;br /&gt;
		prownum[r] = thisrow&lt;br /&gt;
		ic = ic - thisrow&lt;br /&gt;
		r = r + 1&lt;br /&gt;
		-- use the previous if the next is missing and&lt;br /&gt;
		-- make sure we don't overstep the number of images&lt;br /&gt;
		thisrow = math.min(tonumber(pr[r] or thisrow) or ic, ic)&lt;br /&gt;
	end&lt;br /&gt;
	return prownum&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 border = pargs['border'] or args['border'] or ''&lt;br /&gt;
	local align = pargs['align'] or args['align'] or (border == 'infobox' and 'center' or '')&lt;br /&gt;
	local capalign = 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 imgstyle = pargs['image_style'] or args['image_style']&lt;br /&gt;
	local header = pargs['header'] or pargs['title'] or ''&lt;br /&gt;
	local footer = pargs['footer'] or ''&lt;br /&gt;
	local imagegap = tonumber(pargs['image_gap'] or '1') or 1&lt;br /&gt;
	local perrow = nil&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&lt;br /&gt;
	local imagenumbers = {}&lt;br /&gt;
	local imagecount = 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;
		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;
	-- create an array with the number of images per row&lt;br /&gt;
	perrow = getPerRow(dir == 'vertical' and '1' or pargs['perrow'], imagecount)&lt;br /&gt;
&lt;br /&gt;
	-- compute the number of rows&lt;br /&gt;
	local rowcount = #perrow&lt;br /&gt;
&lt;br /&gt;
	-- store the image widths and compute row widths and maximum row width&lt;br /&gt;
	local heights = {}&lt;br /&gt;
	local widths = {}&lt;br /&gt;
	local widthmax = 0&lt;br /&gt;
	local widthsum = {}&lt;br /&gt;
	local k = 0&lt;br /&gt;
	for r=1,rowcount do&lt;br /&gt;
		widthsum[r] = 0&lt;br /&gt;
		for c=1,perrow[r] do&lt;br /&gt;
			k = k + 1&lt;br /&gt;
			if( k &amp;lt;= imagecount ) then&lt;br /&gt;
				local i = imagenumbers[k]&lt;br /&gt;
				if( isnotempty(totalwidth) ) then&lt;br /&gt;
					widths[k], heights[k] = getdimensions(pargs['image' .. i], pargs['width' .. i], pargs['height' .. i])&lt;br /&gt;
				else&lt;br /&gt;
					widths[k] = getWidth(width, pargs['width' .. i])&lt;br /&gt;
				end&lt;br /&gt;
				widthsum[r] = widthsum[r] + widths[k]&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		widthmax = math.max(widthmax, widthsum[r])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- make sure the gap is non-negative&lt;br /&gt;
	if imagegap &amp;lt; 0 then imagegap = 0 end&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;
		widthmax = 0&lt;br /&gt;
		local k = 0&lt;br /&gt;
		for r=1,rowcount do&lt;br /&gt;
			local koffset = k&lt;br /&gt;
			local tw = totalwidth - (3 + imagegap) * (perrow[r] - 1) - 12&lt;br /&gt;
			local ar = {}&lt;br /&gt;
			local arsum = 0&lt;br /&gt;
			for j=1,perrow[r] do&lt;br /&gt;
				k = k + 1&lt;br /&gt;
				if( k&amp;lt;= imagecount ) then&lt;br /&gt;
					local i = imagenumbers[k]&lt;br /&gt;
					local h = heights[k] or 0&lt;br /&gt;
					if (h &amp;gt; 0) then&lt;br /&gt;
						ar[j] = widths[k]/h&lt;br /&gt;
						heights[k] = h&lt;br /&gt;
					else&lt;br /&gt;
						ar[j] = widths[k]/100&lt;br /&gt;
					end&lt;br /&gt;
					arsum = arsum + ar[j]&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			local ht = tw/arsum&lt;br /&gt;
			local ws = 0&lt;br /&gt;
			k = koffset&lt;br /&gt;
			for j=1,perrow[r] do&lt;br /&gt;
				k = k + 1&lt;br /&gt;
				if( k&amp;lt;= imagecount ) then&lt;br /&gt;
					local i = imagenumbers[k]&lt;br /&gt;
					widths[k] = math.floor(ar[j]*ht + 0.5)&lt;br /&gt;
					ws = ws + widths[k]&lt;br /&gt;
					if heights[k] then&lt;br /&gt;
						heights[k] = math.floor(ht)&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			widthsum[r] = ws&lt;br /&gt;
			widthmax = math.max(widthmax, widthsum[r])&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;
		-- compute width of outer div&lt;br /&gt;
		local bodywidth = 0&lt;br /&gt;
		for r=1,rowcount do&lt;br /&gt;
			if( widthmax == widthsum[r] ) then&lt;br /&gt;
				bodywidth = widthmax + (3 + imagegap) * (perrow[r] - 1) + 12&lt;br /&gt;
			end&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;
&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;
&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;
&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;
		if( border == 'infobox' or border == 'none') then&lt;br /&gt;
			div:css('border', 'none')&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;
		local k = 0&lt;br /&gt;
		for r=1,rowcount do&lt;br /&gt;
			for j=1,perrow[r] do&lt;br /&gt;
				k = k + 1&lt;br /&gt;
				if( k &amp;lt;= imagecount ) then&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;
					if ((imagegap &amp;gt; 1) and (j &amp;lt; perrow[r])) then&lt;br /&gt;
						imagediv:css('margin-right', tostring(imagegap) .. 'px')&lt;br /&gt;
					end&lt;br /&gt;
					local i = imagenumbers[k]&lt;br /&gt;
					local img = pargs['image' .. i]&lt;br /&gt;
					local w = widths[k]&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, heights[k],&lt;br /&gt;
						pargs['link' .. i], pargs['alt' .. i],&lt;br /&gt;
						pargs['thumbtime' .. i], pargs['caption' .. i], capalign, imgstyle))&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			-- only float content gives a parent height:0, so add a clearing div&lt;br /&gt;
			if dir ~= 'vertical' then&lt;br /&gt;
				div:tag('div')&lt;br /&gt;
					:css('clear', 'left')&lt;br /&gt;
			end&lt;br /&gt;
		end&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;
	autoscaledimages = false&lt;br /&gt;
	nonautoscaledimages = false&lt;br /&gt;
&lt;br /&gt;
	return renderMultipleImages( frame )&lt;br /&gt;
		.. (autoscaledimages and '[[Category:Pages using multiple image with auto scaled images]]' or '')&lt;br /&gt;
		.. (nonautoscaledimages and '[[Category:Pages using multiple image with manual scaled images]]' or '')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Ane</name></author>
		
	</entry>
</feed>