-- Module: Media
-- Author: "The JoTS"
-- Allows the creation of embedded media objects solely by url, and sizing params.
-- <pre>
local getArgs = require("Dev:Arguments").getArgs;
local utils = require "Module:Utils";
local protocols = {
    ["^File:"] = function(url)
        -- Wiki File
        return mw.html.create "div"
            :wikitext("[[" .. url .. "|180px|link=]]")
                ["overflow-x"] = "auto",
                ["overflow-y"] = "hidden",
                width = "100%"})
    [""] = function(url, args)
        -- Soundcloud
        return mw.html.create "soundcloud"
            :attr("url", url)
            :attr("height", args.height or 75)
            :attr("width", args.width or 200)
            :attr("auto_play", args.auto_play or 0);
    [""] = function(url, args)
        -- YouTube
        local vidId = url:match("?v=([%w_-]+)");
        return mw.html.create "youtube"
                width  = args.width or 150,
                height = args.height or 25});
return {
    url_to_widget = utils.create_wrapper(function(args)
        local url = args.url; -- cannot be the first positional argument as youtube has a "v=", getting interpreted as an param name
        local widget_markup;
        local div_wrapper = mw.html.create "div"
                ["width"]      = "100%",
                ["text-align"] = "center" })
        for pr,func in pairs(protocols) do
            if url:match(pr) then
                widget_markup = tostring( func(url, args) );
        return tostring(div_wrapper:wikitext(widget_markup or url));

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.