| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English | Modul: | Dokumentation | |||
FileMedia – Module with functions for Media files (image pages), adjacent description pages and pages with specific content format.
All functions expect one unnamed parameter with file page (which should be provided to get a meaningful answer). Whitespace ahead and after content is ignored. It might be only the title, a description or media page.
The return value is an empty string (“nothing”), if the parameter value does not fulfil the expectations. If there is a result or the query condition is true, at least one visible character will be returned. The result does not begin or end with a space.
123x456px
0 – existing, but not paged mediaaudio data paged pixel program style vector video
1 – yesaudio data paged pixel program style vector video as well as file image – file is appropriate for file namespace and image also as single picture.
1 – yespx parameterpx.x formats combining image height.
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
| Value | Result | current |
|---|---|---|
nothingfalse |
local version ID | »2025-07-16« |
| Minimal version | version ID required at least date in ISO format It will be compared whether the current local implementation matches this version or later.
|
|
wikidata |
version ID of global upstream
|
»2025-07-16« |
item |
ID of the Wikidata item
|
Q24765326 |
~ |
Corresponding version ID locally and registered at Wikidata
|
»« |
@ |
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described. | ||
A test page illustrates practical use.
All functions described above can be used by other modules per require():
local lucky, FileMedia = pcall( require, "Module:FileMedia" )
if type( FileMedia ) == "table" then
FileMedia = FileMedia()
else
-- error case; FileMedia contains message
return "<span class=\"error\">" .. FileMedia .. "</span>"
end
Subsequently there are available:
If succeeding, the FileMedia.get*() return a string or number, the FileMedia.is*() true (if no exception mentioned); on failure always false.
commons:Data:FileMediaExt.tab defines mapping of file extensions to file types.
General library; no limitations.
None.