Модуль:Meals Lookup: различия между версиями
Mhamster (обсуждение | вклад) non-expensive getimage |
Mhamster (обсуждение | вклад) less expensive getimage |
||
| Строка 31: | Строка 31: | ||
function getimage(frame, fileid) -- should not be invoked | function getimage(frame, fileid) -- should not be invoked | ||
local out = "" | local out = "" | ||
local gifFileTitle = mw.title.new(fileid .. ".gif", "File") | --[[ | ||
WARNING!! THE NEXT THING IS "EXPENSIVE" AND DOES NOT WORKS AFTER 30 OR SMTHNG RUNS | |||
read https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Expensive_properties for more info | |||
local gifFileTitle = mw.title.new(fileid .. ".gif", "File") | |||
local pngFileTitle = mw.title.new(fileid .. ".png", "File") | |||
if gifFileTitle.file.exists then | |||
out = "File:" .. fileid .. ".gif" | |||
elseif pngFileTitle.file.exists then | |||
out = "File:" .. fileid .. ".png" | |||
else | |||
out = "" | |||
end | |||
--]] | |||
-- less expensive variant, but returns only png (AND BIG RED TEXT IF PNG DOES NOT EXISTS) | |||
out = "File:" .. fileid .. ".png" | |||
return out | return out | ||
end | end | ||