Module:Utilities: Difference between revisions

Sur (talk | contribs)
m get_image_file
Sur (talk | contribs)
m px parameterized, default to 15
Line 21: Line 21:
end
end
-- If the image exists exists, return it back, else return a blank string
-- If the image exists exists, return it back enclosed in brackets, else return a blank string
function p.get_image_file(image_file_name)
function p.get_image_file(image_file_name, px)
if (px == nil) then px = 15 end --default
image_file = mw.title.new(image_file_name)
image_file = mw.title.new(image_file_name)
if image_file and image_file.exists then
if image_file and image_file.exists then
    image_file_name = "[[" .. image_file_name .. "|15px]]"
    image_file_name = "[[" .. image_file_name .. "|" .. px .. "px]]"
else
else
    image_file_name = ''
    image_file_name = ''