UsageEdit

{{#invoke:Sandbox/RexxS/Images|getImage}}

Returns a list of the corresponding images from Wikidata or "Noimage.svg" if none exist



local p = {}
 
-- This is used to return an image filename from Wikidata (property p18), or "Noimage.svg" if none exists
p.getImage = function(frame)
	local ent = mw.wikibase.getEntityObject()
	local props = ent:formatPropertyValues('P18')
	local out = {}
	for k, v in pairs(props) do
		if k == 'value' then
			out[#out + 1] = v
		end
	end
	ret = table.concat(out, ", ")
	if #ret == 0 then
		ret = "Noimage.svg"
	end
	return ret
end

return p