https://shaki.info/wiki/index.php?title=Module:InfoboxImage&feed=atom&action=history
Modul:InfoboxImage - Redaktə tarixçəsi
2024-03-29T14:50:09Z
Vikidə bu səhifənin dəyişikliklər tarixçəsi
MediaWiki 1.41.0
https://shaki.info/wiki/index.php?title=Modul:InfoboxImage&diff=799&oldid=prev
WikiSysop: Səhifəni '-- Inputs: -- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link -- size - size to display the image --...' ilə yarat
2020-03-17T18:56:57Z
<p>Səhifəni '-- Inputs: -- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link -- size - size to display the image --...' ilə yarat</p>
<p><b>Yeni səhifə</b></p><div>-- Inputs:<br />
-- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link<br />
-- size - size to display the image<br />
-- maxsize - maximum size for image<br />
-- sizedefault - default size to display the image if size param is blank<br />
-- alt - alt text for image<br />
-- title - title text for image<br />
-- border - set to yes if border<br />
-- center - set to yes, if the image has to be centered<br />
-- upright - upright image param<br />
-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it<br />
-- Outputs:<br />
-- Formatted image.<br />
-- More details available at the "Module:InfoboxImage/doc" page<br />
<br />
local i = {};<br />
<br />
local placeholder_image = {<br />
"Blue - Replace this image female.svg",<br />
"Blue - Replace this image male.svg",<br />
"Female no free image yet.png",<br />
"Flag of None (square).svg",<br />
"Flag of None.svg",<br />
"Flag of.svg",<br />
"Green - Replace this image female.svg",<br />
"Green - Replace this image male.svg",<br />
"Image is needed female.svg",<br />
"Image is needed male.svg",<br />
"Location map of None.svg",<br />
"Male no free image yet.png",<br />
"Missing flag.png",<br />
"No flag.svg",<br />
"No free portrait.svg",<br />
"No portrait (female).svg",<br />
"No portrait (male).svg",<br />
"Red - Replace this image female.svg",<br />
"Red - Replace this image male.svg",<br />
"Replace this image female (blue).svg",<br />
"Replace this image female.svg",<br />
"Replace this image male (blue).svg",<br />
"Replace this image male.svg",<br />
"Silver - Replace this image female.svg",<br />
"Silver - Replace this image male.svg",<br />
"Replace this image.svg",<br />
"Cricket no pic.png",<br />
"CarersLogo.gif",<br />
"Diagram Needed.svg",<br />
"Example.jpg",<br />
"Image placeholder.png",<br />
"No male portrait.svg",<br />
"Nocover-upload.png",<br />
"NoDVDcover copy.png",<br />
"Noribbon.svg",<br />
"No portrait-BFD-test.svg",<br />
"Placeholder barnstar ribbon.png",<br />
"Project Trains no image.png",<br />
"Image-request.png",<br />
"Sin bandera.svg",<br />
"Sin escudo.svg",<br />
"Replace this image - temple.png",<br />
"Replace this image butterfly.png",<br />
"Replace this image.svg",<br />
"Replace this image1.svg",<br />
"Resolution angle.png",<br />
"Image-No portrait-text-BFD-test.svg",<br />
"Insert image here.svg",<br />
"No image available.png",<br />
"NO IMAGE YET square.png",<br />
"NO IMAGE YET.png",<br />
"No Photo Available.svg",<br />
"No Screenshot.svg",<br />
"No-image-available.jpg",<br />
"Null.png",<br />
"PictureNeeded.gif",<br />
"Place holder.jpg",<br />
"Unbenannt.JPG",<br />
"UploadACopyrightFreeImage.svg",<br />
"UploadAnImage.gif",<br />
"UploadAnImage.svg",<br />
"UploadAnImageShort.svg",<br />
"CarersLogo.gif",<br />
"Diagram Needed.svg",<br />
"No male portrait.svg",<br />
"NoDVDcover copy.png",<br />
"Placeholder barnstar ribbon.png",<br />
"Project Trains no image.png",<br />
"Image-request.png",<br />
"Noimage.gif",<br />
}<br />
<br />
function i.IsPlaceholder(image)<br />
-- change underscores to spaces<br />
image = mw.ustring.gsub(image, "_", " ");<br />
-- if image starts with [[ then remove that and anything after |<br />
if mw.ustring.sub(image,1,2) == "[[" then<br />
image = mw.ustring.sub(image,3);<br />
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1");<br />
end<br />
-- Trim spaces<br />
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');<br />
-- remove file: or image: prefix if exists<br />
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then<br />
image = mw.ustring.sub(image,6);<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then<br />
image = mw.ustring.sub(image,7);<br />
end<br />
-- Trim spaces<br />
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');<br />
-- capitalise first letter<br />
image = mw.ustring.upper(mw.ustring.sub(image,1,1)) .. mw.ustring.sub(image,2);<br />
<br />
for i,j in pairs(placeholder_image) do<br />
if image == j then<br />
return true<br />
end<br />
end<br />
return false<br />
end<br />
<br />
function i.InfoboxImage(frame)<br />
local image = frame.args["image"];<br />
<br />
if image == "" or image == nil then<br />
return "";<br />
end<br />
if image == "&nbsp;" then<br />
return image;<br />
end<br />
if frame.args["suppressplaceholder"] == "yes" then<br />
if i.IsPlaceholder(image) == true then<br />
return "";<br />
end<br />
end<br />
<br />
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then<br />
return "";<br />
end<br />
<br />
if mw.ustring.sub(image,1,2) == "[[" then<br />
-- search for thumbnail images and add to tracking cat if found<br />
if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then<br />
return image --.. "[[Категория:Страницы с миниатюрами в карточках]]";<br />
else<br />
return image;<br />
end<br />
elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then<br />
return image;<br />
elseif mw.ustring.sub(image,1,1) == "<" then<br />
return image;<br />
elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then<br />
-- Found strip marker at begining, so pass don't process at all<br />
return image;<br />
else<br />
local result = "";<br />
local size = frame.args["size"];<br />
local maxsize = frame.args["maxsize"];<br />
local sizedefault = frame.args["sizedefault"];<br />
local alt = frame.args["alt"];<br />
local title = frame.args["title"];<br />
local border = frame.args["border"];<br />
local upright = frame.args["upright"] or "";<br />
local center= frame.args["center"];<br />
<br />
-- remove file: or image: prefix if exists<br />
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then<br />
image = mw.ustring.sub(image,6);<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then<br />
image = mw.ustring.sub(image,7);<br />
end<br />
<br />
if maxsize ~= "" and maxsize ~= nil then<br />
-- if no sizedefault then set to maxsize<br />
if sizedefault == "" or sizedefault == nil then<br />
sizedefault = maxsize<br />
end<br />
-- check to see if size bigger than maxsize<br />
if size ~= "" and size ~= nil then<br />
local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0;<br />
local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*"));<br />
if sizenumber>maxsizenumber and maxsizenumber>0 then<br />
size = maxsize;<br />
end<br />
end<br />
end<br />
-- add px to size if just a number<br />
if (tonumber(size) or 0) > 0 then<br />
size = size .. "px";<br />
end<br />
<br />
result = "[[File:" .. image;<br />
if size ~= "" and size ~= nil then<br />
result = result .. "|" .. size;<br />
elseif sizedefault ~= "" and sizedefault ~= nil then<br />
result = result .. "|" .. sizedefault;<br />
else<br />
result = result .. "|frameless";<br />
end<br />
if center == "yes" then<br />
result = result .. "|center"<br />
end <br />
if alt ~= "" and alt ~= nil then<br />
result = result .. "|alt=" .. alt;<br />
end<br />
if border == "yes" then<br />
result = result .. "|border";<br />
end<br />
if upright ~= "" then<br />
result = result .. "|upright=" .. upright;<br />
end<br />
if title ~= "" and title ~= nil then<br />
result = result .. "|" .. title;<br />
elseif alt ~= "" and alt ~= nil then<br />
result = result .. "|" .. alt;<br />
end<br />
result = result .. "]]";<br />
<br />
return result;<br />
end<br />
end<br />
<br />
return i;</div>
WikiSysop