Jump to content

Module:Wide image and Module:Wide image/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
per tp
 
No edit summary
 
Line 79: Line 79:
function wideimage(image, width, height, caption, boxwidth, float, alt, border, capalign, dir)
function wideimage(image, width, height, caption, boxwidth, float, alt, border, capalign, dir)
if image then
if not image then return '' end
image = getfilename(image)
image = getfilename(image)
local iwidth = getwidth(image, width or '0', height or '0')
local imagewidth = getwidth(image, width or '0', height or '0')
if width == nil then
width = iwidth .. 'px'
if width == nil then
width = imagewidth .. 'px'
end
end
local rtl = dir and dir == 'rtl' or nil
local noborder = border and border == 'no' or nil
if tonumber(width) then
width = width .. 'px'
end
local rtl = dir and dir == 'rtl' or nil
local noborder = border and border == 'no' or nil
local maxwidth = noborder and (imagewidth .. 'px') or ((imagewidth + 10) .. 'px')
local r,d = getcontainers(noborder, float or '', boxwidth or 'auto', maxwidth)
cclass = 'noresize '
if not (border == 'no') then
local maxwidth = noborder and (iwidth .. 'px') or ((iwidth + 10) .. 'px')
cclass = cclass .. 'thumbimage'
end
local r,d = getcontainers(noborder, float or '', boxwidth or 'auto', maxwidth)
if tonumber(width) then
width = width .. 'px'
end
cclass = 'noresize '
if not (border == 'no') then
cclass = cclass .. 'thumbimage'
end
d:tag('div')
d:tag('div')
:addClass(cclass)
:addClass(cclass)
:css('overflow', 'auto')
:css('overflow', 'auto')
:css('direction', rtl and 'rtl' or nil)
:css('direction', rtl and 'rtl' or nil)
:wikitext(getimage(image,width,alt,caption or '',rtl))
:wikitext(getimage(image,width,alt,caption or '',rtl))
if caption then
if caption then
d = d:tag('div')
d = d:tag('div')
:addClass('thumbcaption')
:addClass('thumbcaption')
:css('text-align', capalign)
:css('text-align', capalign)
if noborder == nil then
if noborder == nil then
d:tag('div')
d:tag('div')
:addClass('magnify')
:addClass('magnify')
:wikitext('[[:File:' .. image .. '| ]]')
:wikitext('[[:File:' .. image .. '| ]]')
end
d:wikitext(caption)
end
end
d:wikitext(caption)
return tostring(r)
end
end
return ''
return tostring(r)
end
end


function p.main(frame)
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = require('Module:Arguments').getArgs(frame)
local args = getArgs(frame)
return wideimage(
return wideimage(
args['image'] or args[1], args[2] or nil, -- width
args['image'] or args[1],
args[2] or nil, -- width
args['height'] or nil, args['caption'] or args[3],
args['height'] or nil,
args['caption'] or args[3],
args['width'] or args[4], args['align'] or args[5],
args['width'] or args[4],
args['align'] or args[5],
args['alt'], args['border'], args['align-cap'], args['dir']
args['alt'],
args['border'],
args['align-cap'],
args['dir']
)
)
end
end