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.1 (2014-12-17)
MediaWiki 1.19 - 1.23
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

The EmbedVideo Extension is a MediaWiki extension which adds a parser function called #ev for embedding video clips from over 22 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 extract the file(s) in a directory called EmbedVideo in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/EmbedVideo/EmbedVideo.php";
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

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}}

Supported Services[edit | edit source]

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

Site Service Name(s)
Archive.org Videos archiveorg
Bambuser bambuser - Broadcasts bambuser_channel - Channels
Bing/MSN bing msn
Blip.tv blip - Blip requires the full URL to the video page and does not accept the raw ID.
CollegeHumor collegehumor
Dailymotion dailymotion
Div Share divshare
Edutopia Edutopia content moved to YouTube. Please use the youtube service selector below.
FunnyOrDie funnyordie
Gfycat gfycat
Kickstarter kickstarter
Metacafe metacafe
Nico Nico Video nico
RuTube rutube
TeacherTube teachertube
TED Talks ted
Twitch twitch - Live Streams twitchvod - Archived Videos on Demand
Videomaten videomaten
Yahoo Screen yahoo
YouTube youtube - Single Videos youtubeplaylist - Playlists
Vimeo vimeo
Vine vine

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.1 Patch Notes[edit | edit source]

v2.2.0 Patch Notes[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.8 Patch Notes[edit | edit source]

  • Translations updated.
  • Fixed a PHP notice being thrown for the new mobile check.

v2.1.7 Patch Notes[edit | edit source]

v2.1.6 Patch Notes[edit | edit source]

  • Added to the ability to add optional URL arguments to the generated embed URL.

v2.1.5 Patch Notes[edit | edit source]

  • Fixed context in which resource modules are loaded. This resolves an issue with CSS not always applying.

v2.1.4 Patch Notes[edit | edit source]

v2.1.3 Patch Notes[edit | edit source]

v2.1.2 Patch Notes[edit | edit source]

v2.1.1 Patch Notes[edit | edit source]

  • Fixed a logic issue where the $wgEmbedVideoDefaultWidth global override was not obeyed if the video service specified a default width.
  • Actually bumped the version number this time.

v2.1 Patch Notes[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 Patch Notes[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]