Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:StripFilename

From Neodyland Wiki
Revision as of 11:14, 2 March 2015 by commons>SiBr4 (Created page with 'local p = {} function p.main(frame) local f = frame["args"][1] -- Remove namespace prefix f = string.gsub(f,"^[Ff][Ii][Ll][Ee]:(.*)$","%1") f = string....')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Module documentation[ create · purge ]
This documentation is transcluded from Module:StripFilename/doc.
local p = {}

function p.main(frame)
  local f = frame["args"][1]
  -- Remove namespace prefix
  f = string.gsub(f,"^[Ff][Ii][Ll][Ee]:(.*)$","%1")
  f = string.gsub(f,"^[Ii][Mm][Aa][Gg][Ee]:(.*)$","%1")
  -- Remove extension
  e = string.lower(string.gsub(f,"^.*%.([^\.]*)$","%1"))
  if (e=='svg' or e=='png' or e=='jpg' or e=='jpeg' or e=='gif' or e=='tif' or e=='tiff' or e=='xcf' or e=='mid' or e=='ogg' or e=='ogv' or e=='djvu' or e=='oga' or e=='flac' or e=='wav' or e=='webm' or e=='pdf')
    then n = string.gsub(f,"^(.*)%.[^\.]*$","%1")
    else n = f
  end
  return n
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.