Aucun résumé des modifications |
(Combo) |
||
(Une version intermédiaire par le même utilisateur non affichée) | |||
Ligne 54 : | Ligne 54 : | ||
local renvoi = '' |
local renvoi = '' |
||
for i, j in pairs( p.separerImages( args.params ) ) do |
for i, j in pairs( p.separerImages( args.params ) ) do |
||
− | renvoi = renvoi .. p.donnees( args |
+ | renvoi = renvoi .. p.donnees( args['par défaut'] and fusionner( args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j, p.separerParams( args['par défaut'] ) ) or args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j ) |
end |
end |
||
Dernière version du 20 février 2019 à 14:28
Ce module est lié au projet Modèles. Ne l'utilisez pas sur des pages du wiki non-liées à ce projet tant que celui-ci n'est pas terminé.
|
La documentation ci-haut est transcluse de Module:Image/doc. (modifier | historique)
local p = {}
local tableau = require( 'Module:Tableau' )
-- "ext: gif, taille:12" --> { ext = "gif", taille = "12" }
function p.separerParams( chaineInitiale )
local premiereSeparation = tableau.toutRogner( mw.text.split( chaineInitiale, ',%s' ) )
local param = {}
local tousParams = {}
for i, j in pairs( premiereSeparation ) do
if j:find( ':' ) then
param = tableau.toutRogner( mw.text.split( j, ':' ) )
tousParams[param[1]] = param[2]
else
tousParams[1] = j
end
end
return tousParams
end
-- "( ext: gif, taille:12 )(nom : Case)" --> { 1 = "ext: gif, taille:12", 2 = "nom : Case" }
function p.separerImages( chaineInitiale )
local images = tableau.toutRogner( tableau.toutRogner( mw.text.split( chaineInitiale, '%(' ) ), '%)' )
local params = {}
local i = 2 -- 1ère case de 'images' est vide
repeat
params[i-1] = p.separerParams( images[i] )
i = i + 1
until not images[i]
return params
end
local function fusionner( paramUtilisateur, default )
local param = {}
for i, j in pairs( default ) do
param[i] = j
end
for k, l in pairs( paramUtilisateur ) do
param[k] = l
end
return param
end
function p.main( f ) -- fonction dépréciée
return p.pcpl( f )
end
function p.pcpl( f )
local args = tableau.toutRogner( tableau.obtenirArgs( f ) )
if not args.params then error( 'Paramètre "params" manquant', 0 ) end
local renvoi = ''
for i, j in pairs( p.separerImages( args.params ) ) do
renvoi = renvoi .. p.donnees( args['par défaut'] and fusionner( args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j, p.separerParams( args['par défaut'] ) ) or args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j )
end
return renvoi
end
function p.donnees( f )
local args = tableau.toutRogner( tableau.obtenirArgs( f ) )
local nomFichier = 'Image:' .. args.nom .. '.' .. ( args.ext or 'png' )
return '[[' .. nomFichier .. '|' .. math.ceil( ( args.largeur or mw.getCurrentFrame():callParserFunction( '#imgw', nomFichier ) ) * ( args['échelle'] or 1 ) ) .. 'x' .. math.ceil( ( args.hauteur or mw.getCurrentFrame():callParserFunction( '#imgh', nomFichier ) ) * ( args['échelle'] or 1 ) ) .. 'px|' .. ( args.alignement or '' ) .. '|lien=' .. ( args.lien or '' ) .. '|' .. ( args.desc or '' ) .. ']]'
end
return p