var getParam = require("mout/queryString/getParam"); module.exports = function (url) { if (!url) { return ""; } // Youtube if (url.indexOf("youtube.com") !== -1) { // Get the id var videoId = getParam(url, "v"); if (videoId) { return '<iframe width="620" height="400" src="//www.youtube.com/embed/'+videoId+'" frameborder="0" allowfullscreen></iframe>'; } } // Vimeo else if (url.indexOf("vimeo.com") !== -1) { // get the id // e.g. "http://vimeo.com/87110435" var arr = url.split(/http:\/\/vimeo.com\//) var videoId = arr[1]; // insert to embed code return '<iframe src="//player.vimeo.com/video/'+videoId+'" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; } };