mNo edit summary
mNo edit summary
Line 4: Line 4:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local fileName = args[1]
     local fileName = args[1]
     local size = args[2] or '16px'
     local size = args[2] or '20px'
      
      
     if not fileName or fileName == '' then
     if not fileName or fileName == '' then

Revision as of 12:55, 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 '20px'
    
    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:wikitext(string.format('[[File:Icon-Volume.png|%s|link=]]', size))

    return tostring(container)
end

return p