Module:InfoboxImage: Difference between revisions

Jump to navigation Jump to search
m
1 revision
m (1 revision)
 
m (1 revision)
 
(3 intermediate revisions by the same user not shown)
Line 10: Line 10:
--    upright - upright image param
--    upright - upright image param
--    suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it
--    suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it
--    link - page to visit when clicking on image
-- Outputs:
-- Outputs:
--    Formatted image.
--    Formatted image.
Line 42: Line 43:
     "Silver - Replace this image female.svg",
     "Silver - Replace this image female.svg",
     "Silver - Replace this image male.svg",
     "Silver - Replace this image male.svg",
    "Replace this image.svg",
"Cricket no pic.png",
"CarersLogo.gif",
"Diagram Needed.svg",
"Example.jpg",
"Image placeholder.png",
"No male portrait.svg",
"Nocover-upload.png",
"NoDVDcover copy.png",
"Noribbon.svg",
"No portrait-BFD-test.svg",
"Placeholder barnstar ribbon.png",
"Project Trains no image.png",
"Image-request.png",
"Sin bandera.svg",
"Sin escudo.svg",
"Replace this image - temple.png",
"Replace this image butterfly.png",
"Replace this image.svg",
"Replace this image1.svg",
"Resolution angle.png",
"Image-No portrait-text-BFD-test.svg",
"Insert image here.svg",
"No image available.png",
"NO IMAGE YET square.png",
"NO IMAGE YET.png",
"No Photo Available.svg",
"No Screenshot.svg",
"No-image-available.jpg",
"Null.png",
"PictureNeeded.gif",
"Place holder.jpg",
"Unbenannt.JPG",
"UploadACopyrightFreeImage.svg",
"UploadAnImage.gif",
"UploadAnImage.svg",
"UploadAnImageShort.svg",
}
}


Line 54: Line 92:
     -- Trim spaces
     -- Trim spaces
     image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
     image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
     -- remove file: or image: prefix if exists
     -- remove prefix if exists
     if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then
     local allNames = mw.site.namespaces[6].aliases
        image = mw.ustring.sub(image,6);
    allNames[#allNames + 1] = mw.site.namespaces[6].name
     end
    allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
    if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then
     for i, name in ipairs(allNames) do
        image = mw.ustring.sub(image,7);
        if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
            image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
            break
        end
     end
     end
     -- Trim spaces
     -- Trim spaces
Line 83: Line 124:
         return image;
         return image;
     end
     end
     if frame.args["suppressplaceholder"] == "yes" then
     if frame.args["suppressplaceholder"] ~= "no" then
         if i.IsPlaceholder(image) == true then
         if i.IsPlaceholder(image) == true then
             return "";
             return "";
Line 128: Line 169:
         local sizedefault = frame.args["sizedefault"];
         local sizedefault = frame.args["sizedefault"];
         local alt = frame.args["alt"];
         local alt = frame.args["alt"];
        local link = frame.args["link"];
         local title = frame.args["title"];
         local title = frame.args["title"];
         local border = frame.args["border"];
         local border = frame.args["border"];
Line 134: Line 176:
         local center= frame.args["center"];
         local center= frame.args["center"];
          
          
         -- remove file: or image: prefix if exists
         -- remove prefix if exists
         if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then
         local allNames = mw.site.namespaces[6].aliases
            image = mw.ustring.sub(image,6);
        allNames[#allNames + 1] = mw.site.namespaces[6].name
         end
        allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
        if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then
         for i, name in ipairs(allNames) do
            image = mw.ustring.sub(image,7);
            if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
                image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
                break
            end
         end
         end
          
          
Line 174: Line 219:
         if alt ~= "" and alt ~= nil then
         if alt ~= "" and alt ~= nil then
             result = result .. "|alt=" .. alt;
             result = result .. "|alt=" .. alt;
        end
        if link ~= "" and link ~= nil then
            result = result .. "|link=" .. link;
         end
         end
         if border == "yes" then
         if border == "yes" then
14,061

edits

Navigation menu