Module:File link: Difference between revisions

Content deleted Content added
remove "theName" field from readOnlyFields
allow nil values as input to most of the functions, to make call-chaining with conditional variables easier
Line 31:
function data:format(s, filename)
checkSelf(self, 'image:format')
checkType('image:format', 1, s, 'string', true)
checkType('image:format', 2, format, 'string', true)
local validFormats = {
Line 40:
frameless = true
}
if s == nil or validFormats[s] then
data.theFormat = s
data.theFormatFilename = filename
Line 63:
function data:width(px)
checkSelf(self, 'image:width')
checkType('image:width', 1, px, 'number', true)
if px and data.isUpright then
sizeError('image:width')
end
Line 73:
function data:height(px)
checkSelf(self, 'image:height')
checkType('image:height', 1, px, 'number', true)
if px and data.isUpright then
sizeError('image:height')
end
Line 81:
end
function data:upright(isUpright, factor)
checkSelf(self, 'image:upright')
checkType('image:upright', 1, factorisUpright, 'numberboolean', true)
checkType('image:upright', 2, factor, 'number', true)
if isUpright and (data.theWidth or data.theHeight) then
sizeError('image:upright')
end
data.isUpright = trueisUpright
data.uprightFactor = factor
return self
Line 102 ⟶ 103:
function data:location(s)
checkSelf(self, 'image:location')
checkType('image:location', 1, s, 'string', true)
local validLocations = {
right = true,
Line 109 ⟶ 110:
none = true
}
if s == nil or validLocations[s] then
data.theLocation = s
else
Line 122 ⟶ 123:
function data:alignment(s)
checkSelf(self, 'image:alignment')
checkType('image:alignment', 1, s, 'string', true)
local validAlignments = {
baseline = true,
Line 133 ⟶ 134:
bottom = true
}
if s == nil or validAlignments[s] then
data.theAlignment = s
else
Line 144 ⟶ 145:
end
function data:border(hasBorder)
checkSelf(self, 'image:border')
data.checkType('image:border', 1, hasBorder, ='boolean', true)
data.hasBorder = hasBorder
return self
end
Line 152 ⟶ 154:
function data:link(s)
checkSelf(self, 'image:link')
checkType('image:link', 1, s, 'string', true)
data.theLink = s
return self
Line 159 ⟶ 161:
function data:alt(s)
checkSelf(self, 'image:alt')
checkType('image:alt', 1, s, 'string', true)
data.theAlt = s
return self
Line 166 ⟶ 168:
function data:caption(s)
checkSelf(self, 'image:caption')
checkType('image:caption', 1, s, 'string', true)
data.theCaption = s
return self