Module:ResourceLink: Difference between revisions
From Against the Storm Official Wiki
m (editing for debugging) |
No edit summary |
||
Line 34: | Line 34: | ||
strFileSize = "{{ImgH}}" | strFileSize = "{{ImgH}}" | ||
end | end | ||
local strFilePart = string.format("File:%s|%s", strFilename, strFileSize) | local strFilePart = string.format("[[File:%s|%s]]", strFilename, strFileSize) | ||
-- build the link based on the name of the resource passed in | -- build the link based on the name of the resource passed in |
Revision as of 14:40, 2 February 2023
Documentation for this module may be created at Module:ResourceLink/doc
------------------------------------------------------------------------------- -- Renders the {{resourceLink}} template -- -- Takes an argument, the name of the resource. Optionally, accepts a second -- argument, "med" or "large" to render the icon as larger than the standard -- size of text, {{ImgS}} ------------------------------------------------------------------------------- local ResourceLink = {} local IconFilenames = require("Module:IconFilenames") -- lookup table for image filenames function ResourceLink.renderLink(frame) local strResourceName = frame.args.image local strIconSize = frame.args.size local strFilename = IconFilenames.getIconFilename(strResourceName) -- if looking up the provided image name returned nil, then render an error if not strFilename then return "renderIcon Error: file " .. strResourceName .." not found" end -- render the string to return, starting with the file tag, then the link tag -- use the established templates for image sizes, with the default being -- small, or in-line size. local strFileSize = "{{ImgS}}" if "med" == strIconSize then strFileSize = "{{ImgM}}" elseif "large" == strIconSize then strFileSize = "{{ImgL}}" elseif "huge" == strIconSize then strFileSize = "{{ImgH}}" end local strFilePart = string.format("[[File:%s|%s]]", strFilename, strFileSize) -- build the link based on the name of the resource passed in local strLinkPart = "[[" .. strResourceName .. "]]" return strFilePart .. " " .. strLinkPart end return ResourceLink