embed-video
Get embed code for embedding youtube/vimeo/dailymotion/whatever video in websites from URL or ID.
Currently supports YouTube, Vimeo and DailyMotion. Please pull request to add others!
Example
var embed = var vimeoUrl = "http://vimeo.com/19339941"var youtubeUrl = "https://www.youtube.com/watch?v=twE64AuqE9A"var dailymotionUrl = "https://www.dailymotion.com/video/x20qnej_red-bull-presents-wild-ride-bmx-mtb-dirt_sport" consoleconsoleconsole var vimeoId = "6964150"var youtubeId = "9XeNNqeHVDw"var dailymotionId = "x20qnej" consoleconsoleconsole
Output:
Usage
var embed =
embed(url, [options])
Return an HTML fragment embed code (string) for the given video URL. Returns undefined
if unrecognised.
embed.image(url, [options], callback)
Returns an HTML <img>
tag (string) for the given url and the src
in a callback. Works for youtube, vimeo and dailymotion. Returns undefined
if unrecognised.
src: http://img.youtube.com/vi/eob7V_WtAVg/default.jpg, html: <img src="http://img.youtube.com/vi/eob7V_WtAVg/default.jpg"/>
embed.info(url)
Returns an object
containing the video ID, video source ("youtube"
, "vimeo"
, "dailymotion"
), and the original url. Works for youtube, vimeo and dailymotion. Returns undefined
if unrecognised.
id: String url: String source: Enum "youtube" "vimeo" "dailymotion"
Options
query
Object to be serialized as a querystring and appended to the embedded content url.
Example
console
Output:
attr
Object to add additional attributes (any) to the iframe
Example
console
Output:
image
Youtube Image options
option | image |
---|---|
default | |
mqdefault | |
hqdefault | |
sddefault | |
maxresdefault |
embedVideo
Vimeo Image options
option | image |
---|---|
thumbnail_small | |
thumbnail_medium | |
thumbnail_large |
embedVideo
DailyMotion Image options
option | image |
---|---|
thumbnail_60_url | |
thumbnail_120_url | |
thumbnail_180_url | |
thumbnail_240_url | |
thumbnail_360_url | |
thumbnail_480_url | |
thumbnail_720_url | |
thumbnail_1080_url |
embedVideo
Contribute
Feel free to dive in! Open an issue or submit PRs.
License
MIT © Alan Shaw