Module:Excerpt: Difference between revisions

Content deleted Content added
Convert infobox image to thumbnail, even if extracted from an enclosed "File:" link. Also fixed a bug with caption= appearing.
Adding fileargs= to allow images on the left. Minor efficiency improvement (skip text processing on File:... if this image not wanted)
Line 135:
local image = parseimage(token, false) or argimage(token)
if image and checkimage(image) then -- keep comments and templates only within text body
image = mw.ustring.gsub(image, "|%s*frameless%s*%f[|%]]", "") -- make image a thumbnail, not frameless etc.
image = mw.ustring.gsub(image, "|%s*framed?%s*%f[|%]]", "")
if not mw.ustring.match(image, "|%s*thumb%s*%f[|%]]")
and not mw.ustring.match(image, "|%s*thumbnail%s*%f[|%]]") then
image = mw.ustring.gsub(image, "%]%]%s*$", "|thumb]]")
end
files = files + 1
if options.fileflags and options.fileflags[files] then t = t .. image end
image = mw.ustring.gsub(image, "|%s*frameless%s*%f[|%]]", "") -- make image a thumbnail, not frameless etc.
image = mw.ustring.gsub(image, "|%s*framed?%s*%f[|%]]", "")
if not mw.ustring.match(image, "|%s*thumb%s*%f[|%]]")
and not mw.ustring.match(image, "|%s*thumbnail%s*%f[|%]]") then
image = mw.ustring.gsub(image, "(%]%]%s*)$", "|thumb]]%1")
end
if options.fileargs then image = mw.ustring.gsub(image, "(%]%]%s*)$", "|" .. options.fileargs .. "%1") end
t = t .. image
end
end
end
Line 150 ⟶ 153:
if files < maxfile and checkimage(token) then
files = files + 1
if options.fileflags and options.fileflags[files] then t = t .. token end
if options.fileargs then image = mw.ustring.gsub(image, "(%]%]%s*)$", "|" .. options.fileargs .. "%1") end
t = t .. token
end
end
else -- got a paragraph, which ends at a file, image, blank line or end of text
Line 212 ⟶ 218:
options.paraflags = numberflags(args["paragraphs"] or pargs["paragraphs"] or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}
options.fileflags = numberflags(args["files"] or pargs["files"] or "") -- parse file numbers
options.fileargs = args["fileargs"] or pargs["fileargs"]
options.more = args["more"] or pargs["more"]
if options.more and options.more == "" then options.more = "Read more..." end -- more= is short for this default text