Module:PageRef: Difference between revisions
Jump to navigation
Jump to search
SerpentofSet (talk | contribs) m Actually check if the SVG exists |
m check if type is provided first |
||
Line 10: | Line 10: | ||
-- Do some name fiddling where appropriate (can be expanded if new file naming conventions arise) | -- Do some name fiddling where appropriate (can be expanded if new file naming conventions arise) | ||
if (string.lower(type)=="hero") then name = name .. " MM" end -- Hero files are suffixed with MM (minimap) | if (type ~= nil and string.lower(type)=="hero") then name = name .. " MM" end -- Hero files are suffixed with MM (minimap) | ||
-- Try to grab SVG if possible | -- Try to grab SVG if possible |
Revision as of 03:52, 18 October 2024
Documentation for this module may be created at Module:PageRef/doc
local p = {}
-- Generates appropriate filename from name and type
p.getFilename = function(frame)
local name = frame.args[1]
local type = frame.args[2]
-- Prefix with File namespace
name = "File:" .. name
-- Do some name fiddling where appropriate (can be expanded if new file naming conventions arise)
if (type ~= nil and string.lower(type)=="hero") then name = name .. " MM" end -- Hero files are suffixed with MM (minimap)
-- Try to grab SVG if possible
if mw.title.new(name..".svg").exists then
name = name .. ".svg"
else
name = name .. ".png"
end
return name
end
return p