Module:Image

local getArgs = require('Module:Arguments').getArgs local string = require('Module:String') local table = require('Module:Table') p = {}

function p.clearImage(frame) local args = getArgs(frame) local image = args[1] or '' local t = table.map(getArgs(frame), function(v) return v end) if t[1] then table.remove(t, 1) end return p._clearImage(image, t) end

function p._clearImage(img, params) local fr = mw.getCurrentFrame img = img and (img:gsub('^File:',) .. (img:match('%.%a%a%a?%a?$') and  or '.png')) or '' -- check for proper file extension img = fr:callParserFunction( 'filepath', table.merge( { img }, params ) ) if img ~= "" then img = img:gsub('%?.+=.+','') return (' %s?format=original'):format(img) else return string.wrapHtml( 'Bad file name '..img, 'p', { class="error", style="font-weight: bold;" } ) end end

return p