This article, will guide you on embedding videos in a MediaWiki wiki.
With MediaWiki, you can embed videos into your content on a page. You can host the video files with dedicated video file hosting services such as Vimeo, YouTube, etc., or upload directly to your wiki.
If you upload them locally, the video files have their wiki pages, like images and other files on your wiki. Here, the most accessible and suggested format for video files is .mp4. However, you can also upload .webm and .ogv video files to a MediaWiki.
ProWiki uses the EmbedVideo extension by default, which focuses on privacy when embedding videos.
Approach 1: Embed Externally Hosted Video Files
The recommended way to embed video files in MediaWiki is via a dedicated video file hosting service. Just follow the steps:
Step 1: Upload your video to your chosen file hosting service.
Step 2: Obtain the video ID of the respective video.
Step 3: Use the {{#ev:}}
function to embed the video.
The basic syntax is: {{#ev:service-name|video-id}}
Replace service-name with the name of the video hosting service (e.g., 'youtube') and
video-id with the unique identifier of the video you want to embed. For example, if you're
going to embed a YouTube video with the ID 'U65NhBwnCMU,' you would use:
{{#ev:youtube|U65NhBwnCMU}}
Check the EmbedVideo extension documentation for the full list of supported services.
Step 4: Customize the embedded video. This is an optional step.
You can customize the embedded video by adding optional parameters. Some common standard parameters include:
- dimensions: Set the dimensions of the video player. A combination of height and width.
- alignment: Set the alignment of the video player. Possible values are 'left', 'center', and 'right'.
- description: Set a description below the video.
For example, to set the width to 640 pixels, height to 360 pixels, and align the video to the center, you would use:
{{#ev:youtube|U65NhBwnCMU|640x360|center}}
To make embedding easier for beginners, we recommend using named parameters like in the following example:
{{#ev:youtube|id=U65NhBwnCMU|dimensions=640x360|alignment=center}}
This way, one can quickly identify the parameters and even add them in random order.
Check the EmbedVideo extension documentation for the whole list of supported parameters.
Approach 2: Embed Locally Hosted Video Files
If you are very concerned about privacy and want to upload the files locally, you can use the following steps:
Step 1: Upload your video to the wiki.
Step 2: Obtain the page name of the respective video.
Step 3: Use the standard image syntax to embed the video.
The basic syntax is: [[File:ExampleVideo.mp4]]
Step 4: Customize the embedded video. This is an optional step.
You can customize the embedded video by adding optional parameters. Some common standard parameters include:
- width: Set the width of the video.
- alignment: Set the alignment of the video. Possible values are 'left', 'center', and 'right'.
For example, to set the width to 640 pixels and align the video to the center, you would use:
[[File:ExampleVideo.mp4|640px|center]]
Check the EmbedVideo extension documentation for the complete list of supported parameters.
Caveats for Approach 2
Additional configuration required
One needs to do the additional configuration of PHP, the web server, and MediaWiki for more than 2 MB file uploads. See the documentation of file uploads though it only covers MediaWiki. On ProWiki, we have already done all of this configuration for you.
Image authentication on private wikis
One cannot embed locally uploaded files nicely on private wikis using image authentication, which is caused by how this mechanism works. The bigger the file, the longer the time until the video starts playing (30 seconds and more). A sensible file limit is about 25 MB. Try if files up to 75 MB still create a satisfactory experience. To get smaller file sizes, you could reduce the video quality or split the video into content parts if possible.
If acceptable, one can circumvent the issue by using Approach 1, described on this help page: Use unlisted videos with your video hosting service to hide the videos from the public.