مستخدم مجهول
الفرق بين المراجعتين لصفحة: «وحدة:InfoboxImage»
ط
لا يوجد ملخص تحرير
لا ملخص تعديل |
imported>Mr. Ibrahem طلا ملخص تعديل |
||
| سطر ١: | سطر ١: | ||
-- Inputs: | -- Inputs: | ||
-- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link | -- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link | ||
-- page - page to display for multipage images (DjVu) | |||
-- size - size to display the image | -- size - size to display the image | ||
-- maxsize - maximum size for image | -- maxsize - maximum size for image | ||
| سطر ٩٢: | سطر ٩٣: | ||
-- change underscores to spaces | -- change underscores to spaces | ||
image = mw.ustring.gsub(image, "_", " "); | image = mw.ustring.gsub(image, "_", " "); | ||
assert(image ~= nil, 'mw.ustring.gsub(image, "_", " ") must not return nil') | |||
-- if image starts with [[ then remove that and anything after | | -- if image starts with [[ then remove that and anything after | | ||
if mw.ustring.sub(image,1,2) == "[[" then | if mw.ustring.sub(image,1,2) == "[[" then | ||
image = mw.ustring.sub(image,3); | image = mw.ustring.sub(image,3); | ||
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1"); | image = mw.ustring.gsub(image, "([^|]*)|.*", "%1"); | ||
assert(image ~= nil, 'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil') | |||
end | end | ||
-- Trim spaces | -- Trim spaces | ||
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); | image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); | ||
assert(image ~= nil, "mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil") | |||
-- remove prefix if exists | -- remove prefix if exists | ||
local allNames = mw.site.namespaces[6].aliases | local allNames = mw.site.namespaces[6].aliases | ||
| سطر ١٢٢: | سطر ١٢٦: | ||
end | end | ||
function i. | function i.Infobox_Image(args) | ||
local image = | local image = args["image"]; | ||
if image == "" or image == nil then | if image == "" or image == nil then | ||
| سطر ١٣١: | سطر ١٣٥: | ||
return image; | return image; | ||
end | end | ||
if | if args["suppressplaceholder"] ~= "no" then | ||
if i.IsPlaceholder(image) == true then | if i.IsPlaceholder(image) == true then | ||
return ""; | return ""; | ||
| سطر ١٥٨: | سطر ١٦٢: | ||
if mw.ustring.sub(image,1,2) == "[[" then | if mw.ustring.sub(image,1,2) == "[[" then | ||
-- search for thumbnail images and add to tracking cat if found | -- search for thumbnail images and add to tracking cat if found | ||
if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]") or mw.ustring.find(image, "|%s*تصغير | if mw.title.getCurrentTitle().namespace == 0 | ||
and ( | |||
mw.ustring.find(image, "|%s*thumb%s*[|%]]") | |||
or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]") | |||
or mw.ustring.find(image, "|%s*تصغير*[|%]]") | |||
) then | |||
return image .. "[[Category:Pages using infoboxes with thumbnail images]]"; | |||
elseif mw.title.getCurrentTitle().namespace == 0 then | |||
return image .. "[[Category:Pages using deprecated image syntax]]"; | |||
else | else | ||
return image; | return image; | ||
| سطر ١٦٨: | سطر ١٧٩: | ||
return image; | return image; | ||
elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then | elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then | ||
-- Found strip marker at begining, so pass don't process at all | |||
return image; | |||
elseif mw.ustring.sub(image,4,9) == "`UNIQ-" then | |||
-- Found strip marker at begining, so pass don't process at all | -- Found strip marker at begining, so pass don't process at all | ||
return image; | return image; | ||
else | else | ||
local result = ""; | local result = ""; | ||
local size = | local page = args["page"]; | ||
local maxsize = | local size = args["size"]; | ||
local sizedefault = | local maxsize = args["maxsize"]; | ||
local alt = | local sizedefault = args["sizedefault"]; | ||
local link = | local alt = args["alt"]; | ||
local title = | local link = args["link"]; | ||
local border = | local title = args["title"]; | ||
local upright = | local border = args["border"]; | ||
local thumbtime = | local upright = args["upright"] or ""; | ||
local center= | local thumbtime = args["thumbtime"] or ""; | ||
local center= args["center"]; | |||
local right = args["right"]; | |||
local left = args["left"]; | |||
-- remove prefix if exists | -- remove prefix if exists | ||
| سطر ٢١١: | سطر ٢٢٩: | ||
if (tonumber(size) or 0) > 0 then | if (tonumber(size) or 0) > 0 then | ||
size = size .. "px"; | size = size .. "px"; | ||
end | |||
-- add px to sizedefault if just a number | |||
if (tonumber(sizedefault) or 0) > 0 then | |||
sizedefault = sizedefault .. "px"; | |||
end | end | ||
result = "[[File:" .. image; | result = "[[File:" .. image; | ||
if page ~= "" and page ~= nil then | |||
result = result .. "|page=" .. page; | |||
end | |||
if size ~= "" and size ~= nil then | if size ~= "" and size ~= nil then | ||
result = result .. "|" .. size; | result = result .. "|" .. size; | ||
| سطر ٢٢٣: | سطر ٢٤٨: | ||
if center == "yes" then | if center == "yes" then | ||
result = result .. "|center" | result = result .. "|center" | ||
elseif right ~= "" then | |||
result = result .. "|right" | |||
elseif left ~= "" then | |||
result = result .. "|left" | |||
end | end | ||
if alt ~= "" and alt ~= nil then | if alt ~= "" and alt ~= nil then | ||
result = result .. "|alt=" .. alt; | result = result .. "|alt=" .. alt; | ||
| سطر ٢٣٣: | سطر ٢٦٣: | ||
result = result .. "|border"; | result = result .. "|border"; | ||
end | end | ||
if upright ~= "" then | if upright == "yes" then | ||
result = result .. "|upright"; | |||
elseif upright ~= "" then | |||
result = result .. "|upright=" .. upright; | result = result .. "|upright=" .. upright; | ||
end | end | ||
| سطر ٢٤٨: | سطر ٢٨٠: | ||
return result; | return result; | ||
end | end | ||
end | |||
function i.InfoboxImage(frame) | |||
local args = frame.args | |||
return i.Infobox_Image(args) | |||
end | end | ||
return i; | return i; | ||