From CreditorDebtor.com

PmWiki: Media

Here you can find how to embed audio and video players in your wiki pages, either uploaded to the wiki, or on external websites.

The functions are based on the recipe Cookbook:Ape but are somewhat simpler to use and there are differences in the wiki markup.

Enabling the media functions

Media embedding is available since PmWiki 2.5.10, and can be enabled by adding this line to local/config.php:

$PmMedia['EnableEmbed'] = 1;

Basic usage

Embedding media players is similar to embedding images in wiki pages, with the Attach: link or the bare remote URL, without brackets.

To embed a media file into a page, upload the file using the "Attach:" markup, or enter the address (url) of the file into the markup text.

Embedded locally attached file:
Attach:video.webm

Embedded remote file:
https://example.com/video.mp4

Embedded file on the same server, outside of the uploads directory structure:
Path:/some/directory/video.mp4

Links only (not embedded, note the brackets):
[[Attach:video.webm]], [[Attach:video.webm|link text]]
[[https://example.com/video.mp4]]
[[Path:/some/place/video.mp4]]

The following file extensions are expected to be media files that can be embedded:

Locally attached file formats, related files, poster, subtitles

Media support varies between different browsers and devices.

If the link is an external URL, Path:, or InterMap, PmWiki will just embed this file.

If uploads are enabled and this is an Attach: link to a locally uploaded file, PmWiki will scan the uploads directory for alternative files in other formats, and present all to the browser.

For example, if you link to Attach:My-Trip-2026.webm, PmWiki will embed this file. It will also check for files with the same basename and another media extension: My-Trip-2026.mp4, My-Trip-2026.m4v, My-Trip-2026.ogv, My-Trip-2026.mov (in this order) and will include them as alternative formats to the player.

The browser will play the first format it supports; if it supports none of the available formats, it should show direct links to the files so the visitors can download them.

If you can upload only one file, for maximum compatibility, prefer MP4 (H.264/AAC) for video and MP3 for audio.

For best quality with lower file size, prefer WebM (VP9) for video and Opus/Ogg/WebA for audio. These should work in recent browsers.

For best user experience, upload media files in the 2 formats above if you can, and link to the best quality formats (the others should be detected and available in the player).

Video encoding optimized for web

To do.

For locally uploaded files, PmWiki will also search for related pictures and subtitles/captions/chapters, that is the same basename and a different extension, and will include them in the player.

For example, if you link to Attach:My-Trip-2026.webm, if there is an image file My-Trip-2026.jpg, it should appear as the video poster (cover) picture shown before the video starts playing.

If this is an audio file, and there is a related poster file, the player should create a <video> element with the poster as background.

Only for video file formats, the following track files will be automatically added to the player if they are in the uploads directory, and a video file basename.webm is embedded:

You can have more than one related VTT file, all will be added to the player and a user can enable one of these at a time.

Player options

Player options can be set in a hash fragment after the URL. Different player options should be separated by semicolons:

Attach:video.mp4#800x450;loop;t=1:20,5:33

The following options are supported, after the hash sign, separated by semicolons:

Other options exist, see developer.mozilla.org: <video> (except for poster and src).

Configuration variables

The following can be enabled in local configuration:

For subtitles and captions, when a language code is detected, the language name is shown as label in the player. Some language codes and labels are included. You can define other language codes and labels this way:

Links to timestamps / chapters

Timestamps like 0:19 or 1:01:34 written in plain text after the player are converted to links starting the playback at these points:

Attach:video.mp4
The first song starts at 0:19, the end credits at 12:58.
* 0:00 start/intro
* 0:19 first song
* 6:55 second song
* ...
* 12:58 end credits

Another media player, or a page heading of level 1, 2, or 3 like !!! Next Heading will halt the search for timestamps for the current media file.

Differences with Cookbook:Ape

Ape is a popular PmWiki recipe that allows embedding HTML5 video and audio players. This core PmWiki function is based on Ape but is simplified for wiki writers, with less markup to write.

The main differences between PmMedia and Ape are:

  1. No need for %embed%...%% wikistyles; bare URLs are converted to <audio> and <video> HTML5 tags.
  2. Only bare URLs are embedded, like for images; Ape allows for links in brackets to be embedded.
  3. Player options are written in the hash fragment rather than wikistyles.
  4. Automatic detection within local uploads of alternative media formats, poster images and subtitles/captions, no need to link to them.
    • PmMedia has conventions for file name patterns, while Ape allows linking to any file names.
  5. Automatic labeling of many languages for the subtitles/captions.
  6. Video player for audio file + poster.
  7. Links to timestamps do not need to be wrapped in >>embed<< or >>mediajump<<, and are only detected after the video player.
  8. Unlike Ape, PmMedia does not require JavaScript to be enabled (except for the links to timestamps).
  9. Unlike Ape, PmMedia players can be embedded in an Ape map.

The plan is for PmMedia to some day embed videos from YouTube and Vimeo, like Ape, but with better GDPR compliance.

If you're currently using Ape for audio/video file embedding, PmMedia is not a drop-in replacement - the goal was to have less markup/clutter and improve the writer experience. If you enable PmMedia, you also need to check your existing pages and if needed update the wiki markup (remove link brackets, use hash options instead of wikistyles) and possibly rename any alternative/related attached files.

Notes

The web server must send the correct Content-Type headers for all media file formats discussed above.

Apache configuration

To do.

Retrieved from http://creditordebtor.com/index.php/PmWiki/Media
Page last modified on May 12, 2026, at 04:50 AM