Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Other/CheckSizeImage.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local p = {}

function p.main(frame)
local result = ""
local title = mw.title.new(mw.text.trim(frame.args[1]), 6)

if (title ~= nil and title.fileExists) then
local image = title.file
local w = image.width
local h = image.height
local ratio = w/h

-- Nếu tỷ lệ w/h > 2.5 hoặc < 0.5 thì báo lỗi
if (ratio < 0.5 or ratio > 2.5) then
local span = mw.html.create("span"):attr("class", "error"):wikitext("Hình ảnh chọn lọc phải có tỷ lệ chiều rộng/chiều cao từ 0.5 đến 2.5. Hình này đang có tỷ lệ là " .. math.floor(ratio * 100) / 100 .. " [= " .. w .. "/" .. h .. "].")
result = tostring(span)
end
end

return result
end

return p
25 changes: 25 additions & 0 deletions Other/MaxWidthResponsive.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local p = {}

function p.main(frame)
local result = ""
local title = mw.title.new(mw.text.trim(frame.args[1]), 6)

if (title ~= nil and title.fileExists) then
local image = title.file
local w = image.width
local h = image.height
local maxWidth = 430 * (w / h)

-- Nếu chiều cao > chiều rộng (w/h < 1) thì cung cấp max-width
-- để max-height luôn đạt 430px
if (w/h < 1) then
result = "max-width: " .. maxWidth .. "px;"
else
result = "max-width: 430px;"
end
end

return result
end

return p
Loading