<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AWide_image%2Fsandbox</id>
	<title>Module:Wide image/sandbox - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AWide_image%2Fsandbox"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Wide_image/sandbox&amp;action=history"/>
	<updated>2026-04-03T17:44:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Wide_image/sandbox&amp;diff=147651&amp;oldid=prev</id>
		<title>imported&gt;Izno: some slight refactor</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Wide_image/sandbox&amp;diff=147651&amp;oldid=prev"/>
		<updated>2020-12-01T18:18:08Z</updated>

		<summary type="html">&lt;p&gt;some slight refactor&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements [[template:wide image]] and [[template:panorama]]&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function getfilename(s)&lt;br /&gt;
	s = mw.ustring.gsub(s or &amp;#039;&amp;#039;, &amp;#039;^%s*[Ff][Ii][Ll][Ee]%s*:%s*&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	s = mw.ustring.gsub(s or &amp;#039;&amp;#039;, &amp;#039;^%s*[Ii][Mm][Aa][Gg][Ee]%s*:%s*&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	return s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getwidth(s, w, h)&lt;br /&gt;
	w = mw.ustring.gsub(w or &amp;#039;0&amp;#039;, &amp;#039;^%s*(%d+)%s*[Pp][Xx]*%s*$&amp;#039;, &amp;#039;%1&amp;#039;)&lt;br /&gt;
	h = mw.ustring.gsub(h or &amp;#039;0&amp;#039;, &amp;#039;^%s*(%d+)%s*[Pp][Xx]*%s*$&amp;#039;, &amp;#039;%1&amp;#039;)&lt;br /&gt;
	w = tonumber(w) or 0&lt;br /&gt;
	h = tonumber(h) or 0&lt;br /&gt;
	if w &amp;gt; 0 then&lt;br /&gt;
		return w&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local file = s and mw.title.new(&amp;#039;File:&amp;#039; .. mw.uri.decode(mw.ustring.gsub(s,&amp;#039;%|.*$&amp;#039;,&amp;#039;&amp;#039;), &amp;#039;WIKI&amp;#039;))&lt;br /&gt;
	file = file and file.file or {width = 0, height = 0}&lt;br /&gt;
&lt;br /&gt;
	if h &amp;gt; 0 then&lt;br /&gt;
		w = math.floor(h * (tonumber(file.width) or 0)/(tonumber(file.height) or 1) + 0.5)&lt;br /&gt;
		if w &amp;gt; 0 then&lt;br /&gt;
			return w&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	w = tonumber(file.width) or 0&lt;br /&gt;
	return w&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getimage(s, w, a, c, rtl)&lt;br /&gt;
	if c == &amp;#039;thumb&amp;#039; or c == &amp;#039;thumbnail&amp;#039; or c == &amp;#039;frame&amp;#039; or c == &amp;#039;border&amp;#039; then&lt;br /&gt;
		c = s&lt;br /&gt;
	elseif rtl and c ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		c = &amp;#039;&amp;amp;#x202A;&amp;#039; .. c .. &amp;#039;&amp;amp;#x202C;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;#039;[[File:&amp;#039; .. (s or &amp;#039;&amp;#039;) .. &amp;#039;|&amp;#039; .. (w or &amp;#039;&amp;#039;) .. &amp;#039;|alt=&amp;#039; .. (a or &amp;#039;&amp;#039;) &lt;br /&gt;
		.. &amp;#039;|&amp;#039; .. mw.text.unstrip(c or &amp;#039;&amp;#039;) .. &amp;#039;]]&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getcontainers(noborder, float, width, maxwidth)&lt;br /&gt;
	local r = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
	if noborder then&lt;br /&gt;
		if float == &amp;#039;left&amp;#039; then&lt;br /&gt;
			r:addClass(&amp;#039;floatleft&amp;#039;)&lt;br /&gt;
		elseif float == &amp;#039;right&amp;#039; then&lt;br /&gt;
			r:addClass(&amp;#039;floatright&amp;#039;)&lt;br /&gt;
		elseif float == &amp;#039;none&amp;#039; then&lt;br /&gt;
			r:addClass(&amp;#039;floatnone&amp;#039;)&lt;br /&gt;
		else -- center is default&lt;br /&gt;
			r:addClass(&amp;#039;floatnone&amp;#039;)&lt;br /&gt;
			r:css(&amp;#039;margin-left&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
			r:css(&amp;#039;margin-right&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
			r:css(&amp;#039;overflow&amp;#039;, &amp;#039;hidden&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		r:addClass(&amp;#039;thumb&amp;#039;)&lt;br /&gt;
		if float == &amp;#039;left&amp;#039; then&lt;br /&gt;
			r:addClass(&amp;#039;tleft&amp;#039;)&lt;br /&gt;
		elseif float == &amp;#039;right&amp;#039; then&lt;br /&gt;
			r:addClass(&amp;#039;tright&amp;#039;)&lt;br /&gt;
		elseif float == &amp;#039;none&amp;#039; then&lt;br /&gt;
			r:addClass(&amp;#039;tnone&amp;#039;)&lt;br /&gt;
		else -- center is default&lt;br /&gt;
			r:addClass(&amp;#039;tnone&amp;#039;)&lt;br /&gt;
			r:css(&amp;#039;margin-left&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
			r:css(&amp;#039;margin-right&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
			r:css(&amp;#039;overflow&amp;#039;, &amp;#039;hidden&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	r:css(&amp;#039;width&amp;#039;, width)&lt;br /&gt;
	r:css(&amp;#039;max-width&amp;#039;, maxwidth)&lt;br /&gt;
	local d = noborder and r or r:tag(&amp;#039;div&amp;#039;):addClass(&amp;#039;thumbinner&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	return r,d&lt;br /&gt;
end&lt;br /&gt;
	&lt;br /&gt;
function wideimage(image, width, height, caption, boxwidth, float, alt, border, capalign, dir)&lt;br /&gt;
	if not image then return &amp;#039;&amp;#039; end&lt;br /&gt;
	&lt;br /&gt;
	image = getfilename(image)&lt;br /&gt;
	local imagewidth = getwidth(image, width or &amp;#039;0&amp;#039;, height or &amp;#039;0&amp;#039;)&lt;br /&gt;
	if width == nil then&lt;br /&gt;
		width = imagewidth .. &amp;#039;px&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if tonumber(width) then&lt;br /&gt;
		width = width .. &amp;#039;px&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local rtl = dir and dir == &amp;#039;rtl&amp;#039; or nil&lt;br /&gt;
	local noborder = border and border == &amp;#039;no&amp;#039; or nil&lt;br /&gt;
	&lt;br /&gt;
	local maxwidth = noborder and (imagewidth .. &amp;#039;px&amp;#039;) or ((imagewidth + 8) .. &amp;#039;px&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	local r,d = getcontainers(noborder, float or &amp;#039;&amp;#039;, boxwidth or &amp;#039;auto&amp;#039;, maxwidth)&lt;br /&gt;
	&lt;br /&gt;
	d:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;noresize&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;overflow&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;direction&amp;#039;, rtl and &amp;#039;rtl&amp;#039; or nil)&lt;br /&gt;
		:wikitext(getimage(image,width,alt,caption or &amp;#039;&amp;#039;,rtl))&lt;br /&gt;
	if caption then&lt;br /&gt;
		d = d:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;thumbcaption&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;text-align&amp;#039;, capalign)&lt;br /&gt;
		if noborder == nil then&lt;br /&gt;
			d:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;magnify&amp;#039;)&lt;br /&gt;
				:wikitext(&amp;#039;[[:File:&amp;#039; .. image .. &amp;#039;| ]]&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		d:wikitext(caption)&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(r)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame)&lt;br /&gt;
	return wideimage(&lt;br /&gt;
			args[&amp;#039;image&amp;#039;] or args[1],&lt;br /&gt;
			args[2] or nil, -- width&lt;br /&gt;
			args[&amp;#039;height&amp;#039;] or nil,&lt;br /&gt;
			args[&amp;#039;caption&amp;#039;] or args[3], &lt;br /&gt;
			args[&amp;#039;width&amp;#039;] or args[4],&lt;br /&gt;
			args[&amp;#039;align&amp;#039;] or args[5], &lt;br /&gt;
			args[&amp;#039;alt&amp;#039;],&lt;br /&gt;
			args[&amp;#039;border&amp;#039;],&lt;br /&gt;
			args[&amp;#039;align-cap&amp;#039;],&lt;br /&gt;
			args[&amp;#039;dir&amp;#039;]&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Izno</name></author>
	</entry>
</feed>