Anonymous

Module:Icons: Difference between revisions

From Melvor Idle
Icon: Modify link logic to prevent linking to File pages when nolink is specified
m (Icon: Fix issue when overrides amend displayed link text)
(Icon: Modify link logic to prevent linking to File pages when nolink is specified)
(2 intermediate revisions by the same user not shown)
Line 274: Line 274:
["Impossible Longbow"] = 'png',
["Impossible Longbow"] = 'png',
["Throwing Dragon Sword"] = 'png',
["Throwing Dragon Sword"] = 'png',
["Golbin Crate"] = 'png'
["Golbin Crate"] = 'png',
["Bone"] = 'png'
}
}


Line 397: Line 398:
local ovrTxt = txtOverrides[link]
local ovrTxt = txtOverrides[link]
local ovrLink = linkOverrides[link]
local ovrLink = linkOverrides[link]
local ovrTypeExt = typeExtOverrides[iconType]
if ovrTypeExt ~= nil then
ovrTypeExt = ovrTypeExt[img]
end
local ovrExt = extOverrides[img]
local ovrType = typeOverrides[iconType]
local hasText = (text ~= nil and text ~= '')
local hasText = (text ~= nil and text ~= '')
if ovrImg ~= nil and img == link then
if ovrImg ~= nil and img == link then
Line 412: Line 407:
end
end
end
end
-- Type & extension overrides must be after adjustments have been made
-- for any image overrides
local ovrTypeExt = typeExtOverrides[iconType]
if ovrTypeExt ~= nil then
ovrTypeExt = ovrTypeExt[img]
end
local ovrExt = extOverrides[img]
local ovrType = typeOverrides[iconType]
if not hasText and ovrTxt ~= nil then
if not hasText and ovrTxt ~= nil then
text = ovrTxt
text = ovrTxt
Line 449: Line 452:
local txtImg = (iconType ~= nil and iconType ~= '' and img .. '_(' .. iconType .. ')' or img) .. '.' .. ext
local txtImg = (iconType ~= nil and iconType ~= '' and img .. '_(' .. iconType .. ')' or img) .. '.' .. ext
-- Include a link unless no link -and- no text was requested
-- Include a link unless no link -and- no text was requested
local txtLink = (nolink and notext and '' or '|link=' .. link)
local txtLink = '|link=' .. (nolink and notext and '' or link)
resultText = '[[File:' .. txtImg .. '|' .. txtSize .. 'x' .. txtSize .. 'px' .. txtLink .. ']]'
resultText = '[[File:' .. txtImg .. '|' .. txtSize .. 'x' .. txtSize .. 'px' .. txtLink .. ']]'
end
end