Jump to content

Module:RandomImage

Hali sa Wikiquote

Documentation for this module may be created at Module:RandomImage/doc

-- Module:RandomImage
local p = {}

-- List of image data: {filename, article_link_title, caption_text}
-- Add all your image filenames, and the article they should link to, and the caption text.
local image_data = {
    {'Rosalind_Franklin.jpg', 'Rosalind Franklin', 'Rosalind Franklin'},
    {'Rosa_Parks_1996.jpg', 'Rosa Parks', 'Rosa Parks'},
    {'Marie_Curie.jpg', 'Marie Curie', 'Marie Curie'},
    {'Albert_Einstein.jpg', 'Albert Einstein', 'Albert Einstein'},
    {'Kaja_Kallas.jpg', 'Kaja Kallas', 'Kaja Kallas'},
    -- ADD MORE IMAGES HERE!
    -- For example:
    -- {'Some_Other_Person.jpg', 'Some Other Person', 'Some Other Person\'s Name'},
}

function p.get(frame)
    local args = frame.args
    local index = math.random(1, #image_data) -- Selects a random index
    local selected = image_data[index]

    local filename = selected[1]
    local link_title = selected[2] or filename -- Default to filename if no link_title
    local caption_text = selected[3] or link_title -- Default to link_title if no caption_text

    local width = args.width or '200px'
    local thumb = (args.thumb == 'no') and '' or 'thumb|' -- 'thumb' by default, or empty string

    local output = '[[' .. thumb .. 'Ladawan:' .. filename .. '|' .. width .. '|Bago sa Wikisambit: [[' .. link_title .. '|' .. caption_text .. ']]]]'

    return output
end

return p