Skip to content

Embedding Video and External Content

Learnomy overviewFree + ProGet Learnomy →

Learnomy turns a pasted link into a clean, responsive player inside your lesson. Use the Embed lesson content type, or the embed tool in the lesson body, and paste a URL – Learnomy renders the provider’s player. When a link cannot be embedded, you get a tidy link-preview card instead of a broken frame.

  • Embed video and rich media from the sites WordPress already knows – YouTube, Vimeo, and the other built-in oEmbed providers – by pasting the page URL.
  • Embed video from the Fediverse (PeerTube) from any instance, with no per-site setup – paste a /w/, /videos/watch/, or /videos/embed/ link and it plays inline.
  • Fall back gracefully: a link Learnomy cannot embed becomes a clean card with the site name and an Open button, never a broken iframe.
  • Keep every embed looking the same across the lesson editor, the front-end builder, and the student player – one renderer handles all three.
  • Add an embed either as a whole lesson (the Embed content type) or inside a text lesson’s body (the embed tool).

Open a course, add or edit a lesson, and find the Content type dropdown in the lesson editor.

  • For a whole-lesson embed, set Content type to Embed and paste the URL in the media URL field.
  • To place an embed inside a text lesson, keep the content type on Text and use the embed tool in the lesson body, then paste the URL.

Paste the page URL (not an iframe snippet). For a PeerTube video, any of these forms work:

  • https://your-instance.example/w/aBcD1234...
  • https://your-instance.example/videos/watch/aBcD1234...
  • https://your-instance.example/videos/embed/aBcD1234...

Save the lesson and open it in the student player. The video appears in a responsive 16:9 frame. If you see a link card instead of a player, the source does not support embedding (see below).

  • Aspect ratio. Embeds render in a responsive 16:9 frame by default; 4:3 and 1:1 are also supported by the renderer.
  • Fediverse embedding is on by default. Safe hosts only – any URL that resolves to a private or internal network address is never fetched and falls back to a link card. Nothing to configure per instance.
  • Link-card fallback. Any URL that is not a known provider, not a recognised Fediverse platform, and does not advertise oEmbed shows a link-preview card with the host name and an Open button.

If the MediaShield plugin is active, a video you set in a lesson’s video field plays in MediaShield’s protected player whenever that video is in your MediaShield library – with its watermark, watch tracking and protected links. Add the YouTube, Vimeo or self-hosted video to MediaShield first, then use the same URL in the lesson. A video MediaShield does not manage plays in the standard Learnomy player as before.

A “watch X% of the video” completion rule works with either player.

On a Protected video lesson you set the rule on the lesson itself, the same way as for any video: choose Auto: video watched as the Completion rule and set Minimum video watch % (MediaShield 1.4.4 or later). The student sees “Watch 80% of the video: 35% / 80%”, and the line moves each time MediaShield reports how much has been watched. When the student reaches the share, the lesson is marked complete on the spot: the Complete button becomes “Completed” with a Next lesson button, and the video keeps playing. The lesson moves on to the next step by itself only when the video ends. A new Protected video lesson that has no rule yet starts on Auto: video watched at MediaShield’s starting percentage for new lessons (set in MediaShield), whether you create it in an editor, through the REST API, by import or by copying a lesson; you can change it before or after saving. A lesson created or copied with its own rule keeps it, and so does one where you chose the rule yourself before the first save, Manual included.

Updating from MediaShield 1.4.3: its site-wide “Require X% watched” (not the starting percentage for new lessons) moves onto your lessons once, so students are held to exactly what they were before. The first 200 lessons move straight away (on a new site, or one with no site-wide percentage, nothing moves and the move is recorded at once) and any more follow in the background. A Protected video lesson on Manual becomes Auto: video watched at that percentage. One on “All of the above (combined)” gets that percentage as its video rule, unless you had already set one. One on time on page, scroll to end or quiz pass becomes combined: the rule it had plus the video percentage. Lessons created after the move started are left as they were created. MediaShield keeps applying its old setting until the move has finished. With MediaShield 1.4.3 still installed, nothing changes: its site-wide setting keeps holding the Complete button and the lesson editor says so.

Adding a protected video without leaving the lesson

Section titled “Adding a protected video without leaving the lesson”

With MediaShield 1.4.4 or later, the Protected video chooser in the lesson editor (wp-admin and the frontend course builder) has Add a video. Upload or choose a video file, or paste a YouTube, Vimeo or video file link, and click Add: MediaShield adds it to its library and it is picked for the lesson. A link or file already in the library gives you that same video instead of a copy. If MediaShield cannot take the video (for example a page that is not a video), its reason shows under the field. When the library is empty, the chooser points you here. The chooser always shows the lesson’s own video, even in a library too large for the list.

On an ordinary Video lesson that is already saved, Protect this video with MediaShield changes the lesson to Protected video playing the same file or link from your MediaShield library. Its completion rule and Minimum video watch % stay as they are, and students partway through keep their progress. For a YouTube link, MediaShield hides YouTube’s controls and link, but the video itself still lives on YouTube. An uploaded file moves into MediaShield’s protected folder; if another lesson or course still uses the same file, it stays where it is and the editor says so. With an older MediaShield, neither option shows and the chooser works as before.

A MediaShield video used in a lesson plays only for people who can open that lesson: enrolled students, the course’s instructors, administrators, and anyone at all when the lesson is a free preview. A member who is not enrolled cannot fetch its stream or embed link either. When the same video is used in more than one lesson, it plays for anyone who can open any of them. Taking a lesson down does not open its video: while any lesson names the video (a Draft lesson, or one switched to another content type), it stays protected and plays only for the course’s instructors (co-instructors too, when they are switched on) and administrators. A video that no lesson names at all keeps MediaShield’s own access settings.

Section titled “Why some links show a card instead of a player”

Learnomy resolves an embed in this order:

  1. WordPress core oEmbed providers (YouTube, Vimeo, and the rest of the built-in list).
  2. Known Fediverse platforms (PeerTube) by URL shape – no network request, works for every instance.
  3. Safe oEmbed discovery for any other source that advertises oEmbed, after a safety check that blocks private and internal hosts.
  4. A link-preview card, if none of the above produced a player.

So a card means the source did not offer an embeddable player – or the host failed the safety check.

The one renderer is \Learnomy\Content\Embed::render( $url, $opts ). Provider HTML is sanitised through the content render floor, and results are cached per URL. Extension points:

  • learnomy_embed_platform_adapters – register a callable( $url, $host, $path ): ?string that turns a recognised URL shape into sandboxed iframe HTML, so a whole platform works with no per-domain list (PeerTube ships built in).
  • learnomy_embed_fediverse_enabled – filter (default from the learnomy_embed_fediverse option, on) to turn safe oEmbed discovery on or off.
  • learnomy_embed_blocked_hosts – a host deny-list for moderation. Not an allow-list.
  • learnomy_embed_oembed_args – filter the args passed to wp_oembed_get for the core-provider pass.
  • learnomy_embed_html – filter the final wrapped embed markup.

Safe oEmbed discovery is gated by \Learnomy\Security\Webhook_URL_Validator::is_safe(), the same guard used for outgoing webhook URLs, so an author-supplied link that resolves to a private or reserved address is never fetched server-side.

Protected video lessons and MediaShield’s watch rule

Section titled “Protected video lessons and MediaShield’s watch rule”

From MediaShield 1.4.4 the player reports the share it measured on the server through the learnomy_lesson_watched_pct filter (null, $user_id, $lesson, asked only for content type mediashield), and the lesson’s own min_video_watch_pct is the rule. The share the browser sends with Complete and Learnomy’s own heartbeat mark are not used for this type, so a request claiming 100% completes nothing. \Learnomy\protected_video_measured() answers whether anything reports the share; every editor, the REST save and the completion check ask it. learnomy_protected_video_default_watch_pct gives the starting percentage, and learnomy_protected_video_rule_moved ($pct, $count) fires once after the one-time move. While the lesson’s rule is live the player shortcode carries watch_required="<%>", so MediaShield reports the moment the student reaches it. MediaShield 1.4.3 instead adds its site-wide “Require X% watched” rule to a Protected video lesson through the learnomy_lesson_completion_rules filter, measured by its own watch sessions. The lesson page asks GET /learnomy/v1/lessons/{id}/completion-status on load, every 10 seconds, and right after the browser sees MediaShield’s heartbeat request to mediashield/v1/session/heartbeat finish (a resource-timing observer in assets/js/progress-view.js). The server’s answer always decides the button. If MediaShield renames that route, nothing breaks: the button still turns on at the next 10-second check, only later.