Content deleted Content added
Handle {{Sfnm}} |
Limit File: to images to exclude audio files and other detritus. Parse image_flag= (Infobox country) and PD_image=. |
||
Line 13:
local page = mw.ustring.match(image, "([Ff]ile%s*:[^|%]]*)") -- File:(name) ...
or mw.ustring.match(image, "([Ii]mage%s*:[^|%]]*)") -- or Image:(name) ...
if not page then return
-- Limit to image types: .gif, .jpg, .jpeg, .png, .svg, .tiff, .xcf
if not mw.ustring.match(page, "%.[Gg][Ii][Ff]%s*$")
and not mw.ustring.match(page, "%.[Jj][Pp][Ee]?[Gg]%s*$")
and not mw.ustring.match(page, "%.[Pp][Nn][Gg]%s*$")
and not mw.ustring.match(page, "%.[Ss][Vv][Gg]%s*$")
and not mw.ustring.match(page, "%.[Tt][Ii][Ff][Ff]%s*$")
and not mw.ustring.match(page, "%.[Xx][Cc][Ff]%s*$") then return false end
local title = mw.title.new(":" .. page) -- Read description page (for :File:Foo rather than File:Foo)
if not title then return
local redir = mRedirect.getTarget(title)
Line 43 ⟶ 51:
if mw.ustring.match(text, "{{%s*[Ii]nfobox") then
local image = mw.ustring.match(text, "|%s*image%s*=%s*([^}|]*)") -- parse image= argument...
or mw.ustring.match(text, "|%s*PD_image%s*=%s*([^}|]-)")
or mw.ustring.match(text, "|%s*image_flag%s*=%s*([^}|]-)")
or mw.ustring.match(text, "|%s*Cover%s*=%s*([^}|]-)") -- or Cover= from Infobox album
if image then -- add in relevant parameters: caption, alt text and image size
|