Module:Sound: Difference between revisions
m test |
mNo edit summary |
||
| Line 16: | Line 16: | ||
:addClass('sound-button') | :addClass('sound-button') | ||
:attr('data-sound-file', fileUrl) | :attr('data-sound-file', fileUrl) | ||
container:tag('span') | container:tag('span') | ||
Revision as of 12:18, 31 December 2025
Documentation for this module may be created at Module:Sound/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local fileName = args[1]
local size = args[2] or '16px'
if not fileName or fileName == '' then
return '<span style="color:red; font-weight:bold;">Error: No file specified</span>'
end
local fileUrl = frame:callParserFunction('filepath', fileName)
if fileUrl:sub(1,2) == "//" then fileUrl = "https:" .. fileUrl end
local container = mw.html.create('span')
:addClass('sound-button')
:attr('data-sound-file', fileUrl)
container:tag('span')
:addClass('sound-icon-static')
:wikitext(string.format('[[File:Icon-Volume.png|%s|link=]]', size))
container:tag('span')
:addClass('sound-icon-playing')
:wikitext(string.format('[[File:Icon-Volume.gif|%s|link=]]', size))
return tostring(container)
end
return p