Extension:EmbedVideo

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
EmbedVideo

Release status: stable

Implementation Parser function
Description Adds a parser function called #ev for embedding video clips from popular video sharing services.
Author(s) Alexia E. Smith (Alexia E. Smith), Andrew Whitworth (Whiteknight), Jim R. Wilson (Jimbojw), and Mohammad Derakhshani (Mderakhs)
Latest version 2.2.7 (2015-08-14)
MediaWiki 1.19 - 1.25
PHP 5.4+(5.3 up to EmbedVideo 2.2.1)
License The MIT License
Download
Example Gamepedia Help Wiki
Hooks used
ParserFirstCallInit

Translate the EmbedVideo extension if it is available at translatewiki.net

Check usage and version matrix; code metrics
Warning Warning: Please update your installed copies of EmbedVideo to version 2.2.5 or higher if you are running previous versions. There are XSS flaws present in version 2.2.4 and earlier. Please see the download link below under #Installation.

The EmbedVideo Extension is a MediaWiki extension which adds a parser function called #ev for embedding video clips from over 24 popular video sharing services in multiple languages and countries.

Project Homepage
Documentation at Github
Source Code
Source code at Github
Bugs
issues at Github
Licensing
EmbedVideo is released under The MIT License.

Notice: As of the 2.x series the EmbedVideo extension has a new maintainer and an entirely rewritten code base. It retains backwards compatibility with EmbedVideo 1.0 and EmbedVideoPlus.

Installation[edit | edit source]

  • Download and place the file(s) in a directory called EmbedVideo in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
wfLoadExtension( 'EmbedVideo' );
  • YesYDone - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

Those instructions describe the new way of installing extensions since MediaWiki 1.25. If you need to install this extension in earlier versions, instead of wfLoadExtension( 'EmbedVideo' );, you need to use:

require_once "$IP/extensions/EmbedVideo/EmbedVideo.php";

Usage[edit | edit source]

Tags[edit | edit source]

The EmbedVideo parser function expects to be called in any of the following ways:

#ev - Classic Parser Tag[edit | edit source]

  • {{#ev:service|id}}
  • {{#ev:service|id|dimensions}}
  • {{#ev:service|id|dimensions|alignment}}
  • {{#ev:service|id|dimensions|alignment|description}}
  • {{#ev:service|id|dimensions|alignment|description|container}}
  • {{#ev:service|id|dimensions|alignment|description|container|urlargs}}

However, if needed optional arguments may be left blank by not putting anything between the pipes:

  • {{#ev:service|id|||description}}

#evt - Parser Tag for Templates[edit | edit source]

The #evt parser tag allows for key=value pairs which allows for easier templating and readability.

{{#evt:
service=youtube
|id=https://www.youtube.com/watch?v=pSsYTj9kCHE
|alignment=right
}}

<embedvideo> - Tag Hook[edit | edit source]

Videos can easily be embedded with the <embedvideo></embedvideo> tag hook. The ID/URL goes as the input between the tags and parameters can be added as the tag arguments.

<embedvideo service="youtube">https://www.youtube.com/watch?v=pSsYTj9kCHE</embedvideo>

Attributes for Parser Tags[edit | edit source]

Attribute Description
service="(See Supported Services below.)" Required: yes
The video service to call.
id="[id|url]" Required: yes
The raw ID of the video or URL from the player page.
dimensions="[WIDTH|WIDTHxHEIGHT|xHEIGHT]" Required: no, Default: 640
Dimensions in pixels to size the embed container. The standard format is width x height where either can be omitted, but the x must proceed height to indicate it as the height.
Examples: 480, 480x320, x320. If the height is not provided it will be calculated automatically from the width and service default ratio.
Some services such as Gfycat do not have standard heights and should be specified for each embed. $wgEmbedVideoDefaultWidth can be set in LocalSettings.php to override the default width.
alignment="[left|center|right]" Required: no, Default: none
Align the placement of the video either to the left, centered, or to the right.
description="[wiki text]" Required: no, Default: none
Display a description under the embed container.
container="[frame]" Required: no, Default: none
Specifies the container type to use for the embed.
frame: Wrap the video player in a Mediawiki thumbnail box.
urlargs="modestbranding=1&version=3" Required: no, Default: none
Allows extra URL arguments to be appended to the generated embed URL. This is useful for obscure options only supported on one service.

Examples[edit | edit source]

Example #1

For example, a video from YouTube use the 'youtube' service selector enter either the raw ID:

{{#ev:youtube|pSsYTj9kCHE}}

Or the full URL:

{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE}}


Example #2




To display the same video as a right aligned large thumbnail with a description:

{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE|1000|right|Let eet GO|frame}}

For YouTube to have the video start at a specific time code utilize the urlargs(URL arguments) parameter. Take the rest of the URL arguments from the custom URL and place them into the urlargs. Please note that not all video services support extra URL arguments or may have different keys for their URL arguments.

https://www.youtube.com/watch?v=pSsYTj9kCHE&start=76
{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE|||||start=76}}

Supported Services[edit | edit source]

As of version 2.x, EmbedVideo supports embedding video content from the following services:

Site Service Name(s) ID Example URL Example(s)
Archive.org Videos archiveorg electricsheep-flock-244-80000-6 https://archive.org/details/electricsheep-flock-244-80000-6
 https://archive.org/embed/electricsheep-flock-244-80000-6
Bambuser bambuser - Broadcasts bambuser_channel - Channels 5262334 http://bambuser.com/v/5262334
Bing bing 31ncp9r7l http://www.bing.com/videos/watch/video/adorable-cats-attempt-to-eat-invisible-tuna/31ncp9r7l
Blip.tv blip - Blip requires the full URL to the video page and does not accept the raw ID. http://blip.tv/vinylrewind/review-6864612
CollegeHumor collegehumor 6875289 http://www.collegehumor.com/video/6875289/batman-says-his-goodbyes
Dailymotion dailymotion x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms http://www.dailymotion.com/video/x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms
Div Share divshare
Edutopia Edutopia content moved to YouTube. Please use the youtube service selector below.
FunnyOrDie funnyordie c61fb67ac9 http://www.funnyordie.com/videos/c61fb67ac9/to-catch-a-predator-elastic-heart-edition
Gfycat gfycat BruisedSilentAntarcticfurseal http://www.gfycat.com/BruisedSilentAntarcticfurseal
Kickstarter kickstarter elanlee/exploding-kittens https://www.kickstarter.com/projects/elanlee/exploding-kittens
Metacafe metacafe 11404579 http://www.metacafe.com/watch/11404579/lan_party_far_cry_4/
Nico Nico Video nico sm24394325 http://www.nicovideo.jp/watch/sm24394325
RuTube rutube b698163ccb67498db74d50cb0f22e556 http://rutube.ru/video/b698163ccb67498db74d50cb0f22e556/
TeacherTube teachertube 370511 http://www.teachertube.com/video/thats-a-noun-sing-along-hd-version-370511
TED Talks ted bruce_aylward_humanity_vs_ebola_the_winning_strategies_in_a_terrifying_war http://www.ted.com/talks/bruce_aylward_humanity_vs_ebola_the_winning_strategies_in_a_terrifying_war
Tudou tudou mfQXfumwiew http://www.tudou.com/listplay/mfQXfumwiew.html
Twitch twitch - Live Streams twitchvod - Archived Videos on Demand twitchplayspokemon http://www.twitch.tv/twitchplayspokemon
Videomaten videomaten
Vimeo vimeo 105035718 http://vimeo.com/105035718
Vine vine h2B7WMtuX2t https://vine.co/v/h2B7WMtuX2t
Yahoo Screen yahoo katy-perry-dances-sharks-2015-024409668 https://screen.yahoo.com/videos-for-you/katy-perry-dances-sharks-2015-024409668.html
YouTube youtube - Single Videos youtubeplaylist - Playlists pSsYTj9kCHE https://www.youtube.com/watch?v=pSsYTj9kCHE
 https://www.youtube.com/watch?v=CW_PbErQ_c8&list=PL76E80C7F756A2047
Youku youku XODc3NDgzMTY4 http://v.youku.com/v_show/id_XODc3NDgzMTY4.html

Configuration Settings[edit | edit source]

Variable Default Value Description
$wgEmbedVideoMinWidth Integer - Minimum width of video players. Widths specified below this value will be automatically bounded to it.
$wgEmbedVideoMaxWidth Integer - Maximum width of video players. Widths specified above this value will be automatically bounded to it.
$wgEmbedVideoDefaultWidth Integer - Globally override the default width of video players. When not set this uses the video service's default width which is typically 640 pixels.

Patch Notes[edit | edit source]

v2.2.7[edit | edit source]

  • Compatible with Mediawiki 1.24.0+
* https://github.com/Alexia/mediawiki-embedvideo/pull/35

v2.2.6[edit | edit source]

  • NicoNico Video ID fixes; will work with new ID formats.

v2.2.5[edit | edit source]

v2.2.4[edit | edit source]

  • Fix Bing to work with their new URLs.
  • Remove MSN as their new video service does not support embedding.
  • Standardize Tudou support per their wiki.

v2.2.3[edit | edit source]

  • Added support for Youku and Tudou.

v2.2.2[edit | edit source]

  • Updated regular expression replacement pattern for Twitch URLs. Old Twitch embed URLs do not automatically redirect.

v2.2.1[edit | edit source]

v2.2.0[edit | edit source]

  • Fixed a bug with alignment that would cause the left align to not work similar to how Mediawiki handles images and other media.
  • New parser tag better suited for templates; #evt.
  • New HTML like tag format that can take parameters.

v2.1[edit | edit source]

  • The width parameter was changed to dimensions. See parameter documentation above.
  • New container parameter to use a standard Mediawiki thumb frame or default to a generic container.
  • The description parameter no longer forces the thumb frame to be used.
  • Added support for Archive.org, Blip.tv, CollegeHumor, Gfycat, Nico Nico Video, TED Talks, and Vine.
  • Ability to center align embeds.
  • CSS resource module.

v2.0[edit | edit source]

  • URLs from the player pages that contain the raw video ID can now be used as the ID parameter.
  • Validation of the raw IDs is improved.
  • Code base rewritten to have a VideoService class for future extensibility.
  • Switched to HTML5 iframes wherever possible for embeds.
  • All services overhauled to be up to date and working.
  • The 'auto' and 'center' alignment values were removed as they were not working. They are planned to be implement properly in the future.

Developer Notes[edit | edit source]

The major benefit of using a parser function as the injection mechanism for video clips (as opposed to an extension tag) is that parser functions can utilize template parameters (of the form {{{1}}}).

For example, say you found yourself making a lot of YouTube videos in thumbnail size, right-aligned like an image. You might make a template called Template:Youtube_tn which could contain this:

<div class="thumb tright">
{{#ev:youtube|{{{1}}}|{{{2|100}}}}}
</div>

And then call it like this:

{{youtube tn|someYoutubeId}}

Reporting Bugs[edit | edit source]

There is an issue tracker set up on the Github project page.

Contributing[edit | edit source]

Bug reports, feature requests, and patches are always welcome. New contributors can be added to the Github project if there is sufficient interest.

Weblinks[edit | edit source]