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) or {} local image = args[1] or args['image'] or '' if #args > 0 then table.remove(args, 1) end return p._clearImage(image, args) end

function p._clearImage(img, args) 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 }, args ) ) if img ~= "" then img = img:gsub('%?.+=.+','') return img..'?format=original' else return string.wrapHtml( 'Bad file name '..img, 'p', { class="error", style="font-weight: bold;" } ) end end

return p