<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AClean_image2</id>
	<title>Module:Clean image2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AClean_image2"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Clean_image2&amp;action=history"/>
	<updated>2026-05-12T11:40:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:Clean_image2&amp;diff=346&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;-- Removes &#039;File:&#039; prefix, just in case -- Replace {{!}} with | instead of preprocessing -- Turn into a nice wiki file link local p = {} local defaultMaxSize = { 	h = 300, 	w = 300 } p.main = function(frame) 	return p.clean(frame:getParent().args) end  p.clean = function(args) 	local file = args.file 	if not file or (file and (file:lower() == &#039;no&#039; or file == &#039;&#039;)) then 		return nil 	end 	if not file:find(&#039;%[%[File:.-%]%]&#039;) then 		return nil 	end 	local fileRaw = file 	fil...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Clean_image2&amp;diff=346&amp;oldid=prev"/>
		<updated>2024-10-11T20:56:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- Removes &amp;#039;File:&amp;#039; prefix, just in case -- Replace {{!}} with | instead of preprocessing -- Turn into a nice wiki file link local p = {} local defaultMaxSize = { 	h = 300, 	w = 300 } p.main = function(frame) 	return p.clean(frame:getParent().args) end  p.clean = function(args) 	local file = args.file 	if not file or (file and (file:lower() == &amp;#039;no&amp;#039; or file == &amp;#039;&amp;#039;)) then 		return nil 	end 	if not file:find(&amp;#039;%[%[File:.-%]%]&amp;#039;) then 		return nil 	end 	local fileRaw = file 	fil...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Removes &amp;#039;File:&amp;#039; prefix, just in case&lt;br /&gt;
-- Replace {{!}} with | instead of preprocessing&lt;br /&gt;
-- Turn into a nice wiki file link&lt;br /&gt;
local p = {}&lt;br /&gt;
local defaultMaxSize = {&lt;br /&gt;
	h = 300,&lt;br /&gt;
	w = 300&lt;br /&gt;
}&lt;br /&gt;
p.main = function(frame)&lt;br /&gt;
	return p.clean(frame:getParent().args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.clean = function(args)&lt;br /&gt;
	local file = args.file&lt;br /&gt;
	if not file or (file and (file:lower() == &amp;#039;no&amp;#039; or file == &amp;#039;&amp;#039;)) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if not file:find(&amp;#039;%[%[File:.-%]%]&amp;#039;) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local fileRaw = file&lt;br /&gt;
	file = fileRaw:gsub(&amp;#039;%[&amp;#039;,&amp;#039;&amp;#039;):gsub(&amp;#039;%]&amp;#039;,&amp;#039;&amp;#039;):gsub(&amp;#039;[Ff]ile:&amp;#039;,&amp;#039;&amp;#039;):gsub(&amp;#039;{{!}}&amp;#039;,&amp;#039;|&amp;#039;)&lt;br /&gt;
	local fileParts = mw.text.split(file, &amp;#039;|&amp;#039;)&lt;br /&gt;
	file = fileParts[1]&lt;br /&gt;
	&lt;br /&gt;
	local filepage = mw.title.new(file, &amp;#039;File&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	if not (filepage.exists and filepage.file.exists) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local aspect = filepage.file.width / filepage.file.height&lt;br /&gt;
	&lt;br /&gt;
	local maxSize = {&lt;br /&gt;
		h = tonumber(args.maxH) or defaultMaxSize.h,&lt;br /&gt;
		w = tonumber(args.maxW) or defaultMaxSize.w&lt;br /&gt;
	}&lt;br /&gt;
	local size = {&lt;br /&gt;
		h = filepage.file.height,&lt;br /&gt;
		w = filepage.file.width&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	-- iterate in reverse to preserve normal behaviour&lt;br /&gt;
	-- i.e. [[File:a.png|50px|100px]] will be 100px wide&lt;br /&gt;
	for i=#fileParts,2,-1 do&lt;br /&gt;
		local filePart = mw.text.trim(fileParts[i])&lt;br /&gt;
		if filePart:find(&amp;#039;%d+px&amp;#039;) then&lt;br /&gt;
			local mw,mh = filePart:match(&amp;#039;^(%d+)x(%d+)px$&amp;#039;)&lt;br /&gt;
			if mh and mw then&lt;br /&gt;
				size = {&lt;br /&gt;
					h = mh,&lt;br /&gt;
					w = mw&lt;br /&gt;
				}&lt;br /&gt;
			else&lt;br /&gt;
				mh = filePart:match(&amp;#039;^x(%d+)px$&amp;#039;)&lt;br /&gt;
				if mh then&lt;br /&gt;
					size.h = mh&lt;br /&gt;
				else&lt;br /&gt;
					mw = filePart:match(&amp;#039;^(%d+)px$&amp;#039;)&lt;br /&gt;
					if mw then&lt;br /&gt;
						size.w = mw&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if size.h or size.w then&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local newSize = {}&lt;br /&gt;
	if size.h == nil and size.w == nil then&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local newSize = {&lt;br /&gt;
		h = math.floor(math.min(filepage.file.height, maxSize.h, maxSize.w / aspect, size.h, size.w / aspect)),&lt;br /&gt;
		w = math.floor(math.min(filepage.file.width, maxSize.w, maxSize.h * aspect, size.w, size.h * aspect))&lt;br /&gt;
	}&lt;br /&gt;
	return {string.format(&amp;#039;[[File:%s|%sx%spx]]&amp;#039;, file, newSize.w, newSize.h), newSize.w, newSize.h}&lt;br /&gt;
end&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>