Module:Image Du Jour
Apparence
La documentation pour ce module peut être créée à Module:Image Du Jour/doc
local p = {}
-- Fonction : sélectionne un fichier image au hasard depuis Modèle:Liste/ImagesDuJour
function p.afficher(frame)
local titreListe = "Modèle:Liste/ImagesDuJour"
local page = mw.title.new(titreListe)
if not page or not page.exists then
return "<span style='color:red;'>Erreur : la liste des images n'existe pas.</span>"
end
local contenu = page:getContent()
if not contenu then
return "<span style='color:red;'>Erreur : contenu de la liste inaccessible.</span>"
end
local images = {}
for ligne in mw.text.gsplit(contenu, "\n") do
local nom = mw.ustring.match(ligne, "%[%[Fichier:(.-)%]%]")
if nom then table.insert(images, nom) end
end
if #images == 0 then
return "<span style='color:gray;'>Aucune image trouvée dans la liste.</span>"
end
math.randomseed(os.time())
local image = images[math.random(#images)]
return string.format("[[Fichier:%s|300px]]", image)
end
return p