Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 7:
-- Generate the wikitext for the picture
local function pictureWikitext(frame, route, division, roadInfo, args)
local existingFile = ''
 
if roadInfo['pic'] then
local fileName = roadInfo['pic'][1] .. route .. roadInfo['pic'][2]
Line 29 ⟶ 31:
end
end
 
if frame:callParserFunctionmw.title.makeTitle('#ifexistMedia', 'Media:' .. fileName, '1') ~= ''.exists then -- Check if the file exists and record it if it does
existingFile = fileName
local size = 'x20px' -- Default size
-- Override default size with exceptions
if args['size'] then
size = args['size']
elseif route:upper() == '407ETR' then
size = '24px'
elseif division == 'kawartha lakes' then
size = '21px'
elseif args['shield'] == 'yes' and division == 'highway' then
size = 'x25px'
elseif division == 'toll' then
size = 'x30px'
end
return '[[File:' .. fileName .. '|alt=|link=|' .. size .. ']]' -- Return the file wikitext
end
end
if existingFile ~= '' then
fileName = 'Media:RR ' .. route .. ' jct.svg' -- Try fallback file
if mw.title.makeTitle('Media', fileName).exists then -- Check if the fallback file exists and record if it does
existingFile = fileName
end
end
if existingFile == '' then
return '' -- Return nothing if no existing file was found
end
 
local size = 'x20px' -- Default size
if frame:callParserFunction('#ifexist', 'Media:RR ' .. route .. ' jct.svg', '1') ~= '' then -- Check if default image exists
return '[[File:RR ' .. route .. ' jct.svg|alt=|link=|x20px]]' -- Display default image format
-- Override default size with exceptions
if args['size'] then
size = args['size']
elseif route:upper() == '407ETR' then
size = '24px'
elseif division == 'kawartha lakes' then
size = '21px'
elseif args['shield'] == 'yes' and division == 'highway' then
size = 'x25px'
elseif division == 'toll' then
size = 'x30px'
end
return '[[File:' .. fileName .. '|alt=|link=|' .. size .. ']]' -- Return the file wikitext
return '' -- Fallback to returning nothing
end