Module:InfoboxImage: Difference between revisions

no edit summary
(Created page with "-- Inputs: -- 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 -- maxsize - maximum size for image -- sizedefault - default size to display the image if size param is blank -- alt - alt text for image -- title - title text for image -- border - set to yes if border -- center - set to yes, if th...")
 
No edit summary
 
Line 12: Line 12:
--    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
--    link - page to visit when clicking on image
--    class - HTML classes to add to the image
-- Outputs:
-- Outputs:
--    Formatted image.
--    Formatted image.
Line 128: Line 129:


function i.InfoboxImage(frame)
function i.InfoboxImage(frame)
     local image = frame.args["image"] or frame.args['تصویر'];
     local image = frame.args["image"];
      
      
     if image == "" or image == nil then
     if image == "" or image == nil then
Line 164: Line 165:
         -- search for thumbnail images and add to tracking cat if found
         -- search for thumbnail images and add to tracking cat if found
         local cat = "";
         local cat = "";
         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*بندانگشتی%s*[|%]]")) then
         if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then
             cat = "[[رده:صفحاتی که از جعبه اطلاعات همراه تصاویر بندانگشتی استفاده می‌کنند]]";
             cat = "[[Category:Pages using infoboxes with thumbnail images]]";
         end
         end
         return image .. cat;
         return image .. cat;
Line 172: Line 173:
     elseif mw.ustring.sub(image,1,1) == "<" then
     elseif mw.ustring.sub(image,1,1) == "<" then
         return image;
         return image;
     elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then
     elseif mw.ustring.sub(image,1,8) == 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 page = frame.args["page"] or frame.args['صفحه'];
         local page = frame.args["page"];
         local size = frame.args["size"] or frame.args['اندازه'];
         local size = frame.args["size"];
         local maxsize = frame.args["maxsize"] or frame.args['حداکثر اندازه'];
         local maxsize = frame.args["maxsize"];
         local sizedefault = frame.args["sizedefault"] or frame.args['اندازه پیش‌فرض'];
         local sizedefault = frame.args["sizedefault"];
         local alt = frame.args["alt"] or frame.args['جایگزین'];
         local alt = frame.args["alt"];
         local link = frame.args["link"] or frame.args['پیوند'];
         local link = frame.args["link"];
         local title = frame.args["title"] or frame.args['عنوان'];
         local title = frame.args["title"];
         local border = frame.args["border"] or frame.args['حاشیه'];
         local border = frame.args["border"];
         local upright = frame.args["upright"] or frame.args['ایستاده'] or "";
         local upright = frame.args["upright"] or "";
         local thumbtime = frame.args["thumbtime"] or "";
         local thumbtime = frame.args["thumbtime"] or "";
         local center= frame.args["center"] or frame.args['وسط'];
         local center = frame.args["center"];
        local class = frame.args["class"];
          
          
         -- remove prefix if exists
         -- remove prefix if exists
Line 226: Line 225:
         end
         end
          
          
         result = "[[پرونده:" .. image;
         result = "[[File:" .. image;
         if page ~= "" and page ~= nil then
         if page ~= "" and page ~= nil then
             result = result .. "|صفحه=" .. page;
             result = result .. "|page=" .. page;
         end
         end
         if size ~= "" and size ~= nil then
         if size ~= "" and size ~= nil then
Line 235: Line 234:
             result = result .. "|" .. sizedefault;
             result = result .. "|" .. sizedefault;
         else
         else
             result = result .. "|بی‌قاب";
             result = result .. "|frameless";
         end
         end
         if center == "yes" then
         if center == "yes" then
             result = result .. "|وسط"
             result = result .. "|center"
         end
         end
         if alt ~= "" and alt ~= nil then
         if alt ~= "" and alt ~= nil then
             result = result .. "|جایگزین=" .. alt;
             result = result .. "|alt=" .. alt;
         end
         end
         if link ~= "" and link ~= nil then
         if link ~= "" and link ~= nil then
             result = result .. "|پیوند=" .. link;
             result = result .. "|link=" .. link;
         end
         end
         if border == "yes" or border == "بله" then
         if border == "yes" then
             result = result .. "|حاشیه";
             result = result .. "|border";
         end
         end
         if upright == "yes" or upright == "بله" then
         if upright == "yes" then
             result = result .. "|ایستاده";
             result = result .. "|upright";
         elseif upright ~= "" then
         elseif upright ~= "" then
             result = result .. "|ایستاده=" .. upright;
             result = result .. "|upright=" .. upright;
         end
         end
         if thumbtime ~= "" then
         if thumbtime ~= "" then
             result = result .. "|thumbtime=" .. thumbtime;
             result = result .. "|thumbtime=" .. thumbtime;
        end
        if class ~= nil and class ~= "" then
            result = result .. "|class=" .. class;
         end
         end
         -- if alt value is a keyword then do not use as a description
         -- if alt value is a keyword then do not use as a description
         if alt == "thumbnail" or alt == "بندانگشتی" or alt == "thumb" or alt == "انگشتی" or
         if alt == "thumbnail" or alt == "thumb" or alt == "frameless" or alt == "left" or alt == "center" or alt == "right" or alt == "upright" or alt == "border" or mw.ustring.match(alt or "", '^[0-9]*px$', 1) ~= nil then
        alt == "frameless" or alt == "بی‌قاب" or alt == "left" or alt == "چپ" or
        alt == "center" or alt == "وسط" or alt == "right" or alt == "راست" or
        alt == "upright" or alt == "ایستاده" or alt == "border" or alt == "حاشیه" or
        mw.ustring.match(alt or "", '^[0-9۰-۹]*px$', 1) ~= nil then
             alt = nil;
             alt = nil;
         end
         end
Line 273: Line 271:
         if title ~= "" and title ~= nil then
         if title ~= "" and title ~= nil then
             result = result .. "|" .. title;
             result = result .. "|" .. title;
        elseif alt ~= "" and alt ~= nil then
            result = result .. "|" .. alt;
         end
         end
         result = result .. "]]";
         result = result .. "]]";
confirmed, Administrators
330

edits