Video helpers

The functions that turn a lesson's video URL into a player, and the pieces you can use separately.

Rendering a lesson video

pom_lms_get_lesson_video_markup( array $lesson_metas ): string

Returns the complete markup for a lesson's video, given the lesson's stored fields. It normalizes the URL, works out the provider, fetches a thumbnail, requests the theme's video assets, and returns the player the current theme expects.

This is the function to call if you are rendering lesson video anywhere other than the lesson template — a shortcode, a course preview, a custom layout.

It returns an empty string when the lesson has no video URL.

Identifying the provider

pom_lms_get_lesson_video_source( string $video_url, string $video_source = '' ): string

Returns youtube, vimeo, or an empty string.

It works the URL out for itself, and only falls back to the stored video type when the URL is not recognizable. That ordering is deliberate: the URL is the evidence, the stored type is the hint.

An empty return does not mean the video is unusable — it means it is neither YouTube nor Vimeo, and the renderer falls back to a plain embedded frame.

Extracting identifiers

pom_lms_extract_youtube_video_id( string $video_url ): string
pom_lms_extract_vimeo_video_id( string $video_url ): string

Return the video identifier, or an empty string if the URL is not that provider's.

The YouTube extractor understands the forms editors actually paste: watch URLs, short youtu.be links, embed URLs, shorts and live URLs. That is why the lesson field accepts a URL copied from the browser bar rather than demanding an embed code.

Thumbnails

pom_lms_get_lesson_video_thumbnail_url( string $video_url, string $video_source ): string

Returns a thumbnail URL for the video, or an empty string.

YouTube thumbnails are derived from the identifier. Vimeo thumbnails are not derivable, so they are looked up and cached — the lookup does not happen on every page render.

Useful for building course cards and lesson lists that show a still without setting a featured image on every lesson.

Unrecognized providers

A URL that is neither YouTube nor Vimeo is embedded in a plain frame pointing at the URL you supplied.

That is a genuine escape hatch — a self-hosted player, an enterprise video platform, an internal service — with one condition: the URL must be embeddable. A link to a page that refuses to be framed produces an empty box.

Test any non-standard provider on the front end before publishing lessons with it.

Access first

These helpers render video. They do not check access.

if ( ! pom_lms_user_can_access_lesson( $lesson_id, $course_id ) ) {
    return '';
}

echo pom_lms_get_lesson_video_markup( $lesson_metas );

Rendering a player for a blocked lesson publishes the video URL to someone who should not have it. See The access control contract.

Privacy of video hosting

The video itself is served by YouTube or Vimeo, which see your students' requests. Unlisted videos are unlisted, not private — anyone with the URL can watch, whether or not they bought the course.

If a course's value depends on the video being unobtainable, hosting it on a public video service is the wrong architecture, and no access setting in POM LMS changes that.

Reading the lesson's fields

$lesson_metas = pom_lms_get_post_metas( $lesson_id );

Returns the lesson's stored fields as an array, which is what the markup helper expects. Use it rather than reading storage directly, so your code keeps working if the storage shape changes.