Summary: Talk page for Ape: Automagical PmWiki Embed.
Maintainer: Petko
Users: +6 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Please post new sections below this line. You can type 4 tildes ~~~~ to insert your name and the date-time stamp.

How to set HTML span element height to be taller than the HTML video element?

Setting height of an embed video sets the HTML span element and the HTML video element to the same value.
Is there a way to set the span element height to 'auto' and the video element height to '240px'?

This would useful to have text or a caption inside the span on top of the video without having the video displaying partway below the span outline box.


Yes, you can set the video height with CSS like video {height: 240px !important} which will override the calculated height on individual video frames. --Petko

Excellent. That works.

Why when it has a caption on top and has a poster you must insert a [[<<]] between the caption and the link?

%frame rfloat video embed width=320px height=auto%Original - No Bass[[<<]][[{$:video2}|{$:poster2}]]%%


I see the problem, there is a caption inside the %embed% element. You may want to place the caption outside the embed element, and not force resize the video, something like this. --Petko

>>rframe width=320px<<
!!!!! Caption here
%embed% [[Attach:video.webm|Attach:poster.wepb]]
Your lyrics here.

Can you make ape use a very simple playlist so when one piece finishes it will start the next?

Perhaps something like this:

(:playlist my_guitar_samples:)
	Title1=Guitar Sample 1 

	Title2=Guitar Sample 2

	Title3=Guitar Sample 3
(:playlist end:)
%embed width=100pct height=400px playlist=my_guitar_samples%

Can the mediajump block do this?


The answer is no, Ape or mediajump cannot. Sorry, I've been under a lot of work and pressure for the last several weeks, and not enough sleep, and cannot work on this at the moment. --Petko

[Solved] Set start point of video when play button clicked

Is there a way to have the video/audio player start at 42 seconds when the play button is clicked? You can add text links that you can click to start a video at a particular point in the video, for example 42 seconds, they get added below the video. A use could start earlier if they want by dragging the position indicator, but I want a video to start at 42 seconds.


For YouTube videos, you can add ?start=42 to the video link. This is the number of seconds, 5 minutes would be 300. --Petko

What about a local copy of a video? Not just YouTube

You can do %embed% https://wiki/uploads/video.mp4#t=42 %% with the full URL, not Attach:video.mp4#t=42. See documentation section HTML5 audio and video and "Links to Timestamps". --Petko

That does the same thing, creates a text link to 42. Perhaps a better way to say this is I want to pre-queue forward the video so when you click the button in the middle of the video window it is already set at 42 seconds. The slider would already be slid to the right for 42 seconds when it displays. Is there a way to set properties/attributes to pre-set the position of the slider when the video area on the wikipage is initially displayed without using a intermediary text link?

Yes you can, as I wrote, just add #t=42 to the full video URL, see as an example the first video here which starts at 11 seconds. --Petko

It is clearly working on PMWiki. I am using ubuntu 22.10 with php 8.3.1, the newest pmwiki and firefox 119.0.1 its on a local machine and the server is "php -S localhost:8000". Everything else works.

  %embed% http://localhost:8000/guitarstuff/video/imagine.mp4#t=11

does not queue.

Can I please upload the file to the Ape-Sandbox for testing? It runs into the size limit. Its 7.5 M.

I've temporarily increased it to 8M. --Petko

I have tested it in the the Ape-Sandbox and it works, so something else is wrong. Time for me to debug more.

BTW alternatively you can cut the video with ffmpeg, something like this:

# without recoding the streams
ffmpeg -ss 42 -i video.mp4 -c copy -avoid_negative_ts 1 output_copy.mp4

# recode the streams if blank delay or A/V mismatch:
ffmpeg -ss 42 -i video.mp4 -c:v libx264 -c:a aac \
   -b:a 192k -avoid_negative_ts 1 output_recode.mp4

Here -ss 42 means start at 42 seconds. --Petko

On my machine using your URL it works, but using my localhost URL it does not queue at all.

 Queue works great on my machine:
   %embed% https://galleries.accent.bg/uploads/Cookbook/Ape-Sandbox/imagine.mp4#t=42

 Does not queue video on my machine:
   %embed% http://localhost:8000/guitarstuff/video/imagine.mp4#t=42

Could it possibly be not parsing the URL wrongly because it has "localhost:8000" ? Did I format my URL incorrectly?

Not sure, it should work with the port number. But also try %embed% Path:/guitarstuff/video/imagine.mp4#t=42 --Petko

 This did not queue the video at all:

     %embed% Path:/guitarstuff/video/imagine.mp4#t=42

I tried several variations, the video only plays from beginning. :(

The only way the Queue works:

   %embed% https://galleries.accent.bg/uploads/Cookbook/Ape-Sandbox/imagine.mp4#t=42

The same video from different locations displayed on the same wiki page at the same time.
The one referenced from the Ape-Sandbox queues and plays, the one from my
local wiki directory plays but will not queue. I also tried putting one before the other
and it made no difference.

Appears they both just output an Anchor element, so the problem appears to be the browser
does not like to queue video with links that are not of normal average internet website
type of links, IE hard paths, or 'localhost:8000', etc.

PMWiki outputs this HTML:

 <a class='urllink' href='https://galleries.accent.bg/uploads/Cookbook/Ape-Sandbox/imagine.mp4#t=42' rel='nofollow'>https://galleries.accent.bg/uploads/Cookbook/Ape-Sandbox/imagine.mp4#t=42</a>

 <a class='urllink' href='/guitarstuff/video/imagine.mp4#t=42' rel='nofollow'>Path:/guitarstuff/video/imagine.mp4#t=42</a>

According to documentation I found find, PMWiki is applying a "media fragment description" to the file path.


First I found this in PMWiki MDN
Media fragments are a W3C recommendation W3C

Here is the W3C specs for URLs W3C URL

Why would it only work with "normal" internet links? I will have to dig more into URL specs. Perhaps I can find something there.

I think I found the reason: the simple PHP server doesn't implement the HTTP header Range: and also Accept-Bytes: and Content-Range: so the browser cannot fast-forward to a specific timestamp of a video without downloading the portion before the timestamp.

If your video is in the PmWiki's uploads directory, you can use the action=download core action to allow the browser to download a video range -- I've implemented download ranges in PmWiki (version 2.3.24 from 2023-06-06). The following works for me, the video is forwarded to 42 seconds:

   %embed% http://localhost:8000/pmwiki.php?n=Main.Ape?action=download&upname=imagine.mp4#t=42

To make this easier, you can add a Site.InterMap prefix, say "Downloads:"

   Downloads: {*$PageUrl}?action=download&upname=$1

Then in a wiki page, use:


Obviously, the prefix will work for files attached to the same wikigroup, or in per-page upload directories, to the same page.

Alternatively, you can either enable the Apache server, or split the video with ffmpeg to the precise timestamps you need. --Petko

Affects audio too. When media fragment "#t=5" is appended it shows link but not the player.
Clicking the link goes to a blank page with the player. Ape-Sandbox

Start and end times weren't implemented for audio files, until version 20240111 (just released). --Petko

Upgrading the Ape recipe fixed it all up real good! The audio is fixed, and I think it also fixed
another issue with the video that I did not bring up. I recommend anyone using Ape to upgrade to
the newest version.

I did switch from the PHP web server to Apache and now things work a LOT better.


[Solved] Disable mouse scroll

I find %map% particularly useful. When the cursor is over the map, scrolling the mouse wheel zooms the map, yet for the rest of the wiki page it scrolls the page. It is possible to disable or alter this behaviour, e.g. to change zoom over the map to the 'ctrl-scroll mouse wheel'?


It will be possible to disable the scroll wheel zoom for OpenStreetMap maps with the latest version 20230312. You can do something like this in the file pub/ape/ape-local.js: --Petko

var OSMapOptions = {
  scrollWheelZoom: false
sessionStorage.setItem("OSMapOptions", JSON.stringify(OSMapOptions));

[Solved] How to add new video format?

I want to add .MOV container format as it can be played in modern browsers if video inside is encoded as h264 or h265.

uAPErx.push([/^(.*\.(mp4|webm|ogv|vtt|mov))$/i, 'video']);
uAPErx.push([/^(.*\.(mp4|webm|ogv|mov)#t=[\d,.:]+)$/i, 'video']);

I added this to ape-local.js.
It works, but it would be better to add also mov: 'video/mp4', to var contenttypes{} in ape.js. Is it possible?


Added as 'video/quicktime'. This should be made configurable, next time someone needs it. --Petko

[Solved] Display as inline blocks horizontally

I'm using several %map nztopo height=300px width=300px% Attach:[=my.gpx=] %% in a row. How do I configure these so they are treated as inline blocks, all appearing "on the same" line (i.e. horizontally), rather than blocks all 'clearing' each other and displaying vertically?

You can add to pub/css/local.css the following. --Petko

.map.nztopo {
  display: inline-block;

[Closed] Space before closing %%

Just a note that %embed% https://youtu.be/w7TBR907qp4%% fails to play, but %%%embed% https://youtu.be/w7TBR907qp4 %% work just fine

simon December 16, 2021, at 08:27 AM

Indeed, your link is eating the percent signs: https://youtu.be/w7TBR907qp4%% (in fact YT appears to detect this and redirect to the correct one from the link, but apparently not from the <iframe>). Ape shouldn't filter out the percent signs which are allowed and valid in a URL. --Petko December 16, 2021, at 08:34 AM

[Tip] Display YouTube subtitles

With YouTube videos, if there is a subtitle file present, you can have it automatically displayed by adding


to the URL. Example:

%embed width=960px height=450px% https://www.youtube.com/watch?v=mWnFnzuUIjk?cc_load_policy=1 %%

-- kellerfrau

[Closed] Cross-origin scripts, wikifarms, etc.?

The config instructions for Ape note that “Browsers do not allow scripts from one domain to read the content of pages on other domains, and Ape needs to read the current page to get the link(s).” (and the suggested solution [in the case of wikis on the same farm but different domains] is copying the ape directory to the pub/ for the individual other-domain wiki(s).

However… I think there might be some confusion here (possibly on my part w.r.t. the instructions?). Here is why I say that:

  1. I have a wikifarm with wikis across several domains; Ape is installed (only in $FarmD/pub, not in pub/ of individual wikis); all wikis can use it (no browser errors or anything, and embedding works fine, etc.)
  2. This StackOverflow answer says this:
    All URL based security restrictions in client side JavaScript are based on the URL of the webpage containing the <script> element which loads the JS.
    The URL the JS itself is hosted at is irrelevant.
  3. There are recipes (such as Sage Cell) which load scripts not just from other domains in a wikifarm, but from all sorts of places (third-party websites, CDNs, etc.), and they also work (at least, in every browser I have tested them in)

Am I misunderstanding the instructions, or the use case to which they are meant to apply?

Said Achmiz January 06, 2018, at 02:20 PM

It is the multiple-pin map frame that doesn't work from a different domain, see the comment at the very bottom of this page. I'll update the docs. --Petko January 06, 2018, at 06:41 PM

Ahh, I see! Thank you, that makes sense. —Said Achmiz January 06, 2018, at 08:24 PM

[Closed] WikiFarm issue

When I try this recipe in my farm's local wiki, it all seems to work properly. However, when I try it in a field of that same farm, most of it works, but the following markup shows "Embedding" with no map. Where might the problem lay?

: %list embed width=100pct% 51.5728226,-0.3171152  :  [[NPH/ | Northwick Park]]
: 51.3771046,-0.5286385  :  [[SPH/ | St Peters]]
: 51.5041414,-0.0867275  :  [[STH/ | Tommies]]

-- RandyB September 02, 2015, at 12:51 AM

I use the recipe both on a single -no-farm- wiki, and in 2 fields of a farm. Make sure $FarmPubDirUrl is correctly defined in the field (it probably is), and that your browser can load the file leaflet.js from the field. Try also reloading/refreshing the browser cache, or test it with a different browser. Is there a public URL where I can test it? --Petko September 02, 2015, at 11:27 AM

Thanks, Petko. I've got it working now. I put Ape in all my field pub directories, and refer to those directories in my configuration file when I load Ape. You suggested in a very helpful email the idea of creating symlinks, and pointed out that I could do that via PHP (http://php.net/symlink). I like your proposed solution better than what I did. I may try it when I understand more of what I'm doing. -- RandyB September 04, 2015, at 12:53 AM

Added a note in the page. --Petko September 05, 2015, at 05:06 AM

[Closed] Older discussions

Older discussions were moved to Ape-Talk-Archive.

Please add new sections at the top of the page. --Petko

Talk page for the Ape: Automagical PmWiki Embed recipe (users).