
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Image/man (modifica · cronologia)
Sandbox: Modulo:Image/sandbox (modifica · cronologia) · Test: Modulo:Image/test (modifica · cronologia · Esegui)
- Utilizza: Modulo:Wikidata
- Utilizzato da: Template:GetBestImage
--[[ Source script: https://it.wikivoyage.org/wiki/Modulo:Image Maintainer: Andyrom75 ]] local getProperty = require('Modulo:Wikidata')._getProperty local entityId = '' local WDBanner = '' local WDFoto = '' local WDTitolo = '' local function _isDefined(s) return s ~= '' and s end local function _fetchWD(args) entityId = _isDefined( args[1] or args.da or args.from ) or mw.wikibase.getEntityIdForCurrentPage() WDBanner = getProperty( { 'P948', from = entityId, n = 1 } ) WDFoto = getProperty( { 'P18', from = entityId, n = 1 } ) WDTitolo = mw.wikibase.getLabel( entityId ) end local function _getPicture(args) local fotopx = _isDefined(args.fotopx) or '100px' local fotodesc = _isDefined(args.fotodesc) or _isDefined(args.desc) or ((_isDefined(WDTitolo) and (WDTitolo..' ') or '').. '(immagine)') return WDFoto and string.format('[[File:%s|%s|%s]]', WDFoto, fotopx, fotodesc) or 'Nessuna immagine presente in archivio' end local function _getBanner(args) local banner = WDBanner or 'Pagebanner default.jpg' local bannerpx = _isDefined(args.bannerpx) or '300px' local bannerdesc = _isDefined(WDBanner) and (_isDefined(args.bannerdesc) or _isDefined(args.desc) or ((_isDefined(WDTitolo) and (WDTitolo..' ') or '').. '(banner)')) or 'Nessuna immagine presente in archivio' return string.format('[[File:%s|%s|%s]]', banner, bannerpx, bannerdesc) end local p = {} function p.getPicture(frame) local args = frame.args _fetchWD(args) return _getPicture(args) end function p.getBanner(frame) local args = frame.args _fetchWD(args) return _getBanner(args) end function p.getBestImage(frame) local args = frame.args _fetchWD(args) return not WDBanner and WDFoto and _getPicture(args) or _getBanner(args) end return p