How to write a web source/custom embed

13 Jul 2015


The PHPVibe cms uses a tone of web sources, through web sources people can easily generate a video autoembed by submitting just the link.

We will be using the logic of the plugins system to achieve a new source without touching the code from lib/class.providers.php

First, let’s add our new source to the supported array of websites.

function newSourceName($hosts = array()){
$hosts[] = '';
return $hosts;

And hook it with a simple filter
add_filter('vibe-video-sources', 'newSourceName');

Now let’s provide the embed logic:

function EmbednewSourceName($txt =''){
global $vid;
if(isset($vid)) {
if($vid->VideoProvider($vid->theLink()) == '' ) {
$link = $vid->theLink();
if(!nullval($link)) {
$id = $vid->getVideoId("video/", '/'); //* Id extraction logic. Let's say the url has the id after /video , example *//
if(!nullval($id)) {
$tembed = ' < iframe(? object, etc) width="' . get_option('video-width') . '" height="' . get_option('video-heigth') . '" src="//'.$id.'" frameborder="0" allowfullscreen scrolling="no"> ';
$txt .= $tembed;
/* End link check */
/* End provider check */
/* End isset(vid) */
/* End function */
return $txt;

So now we have the function which gets the link to the external video source and turns it into an iframe embed.
Let’s hook it to the PHPVibe embeds through the filter EmbedModify.
add_filter('EmbedModify', 'EmbednewSourceName');

Now we have a new source of embeds for our visitors.

If you can scrape, or the source returns details (thumbnails, duration, title, description, tags), you can hook this also:

function DetailsnewSourceName($txt = ''){
global $vid,$websLink;
if(!isset($vid) && isset($websLink)) {
$vid = new Vibe_Providers($websLink);
if(isset($vid)) {
$link = $vid->theLink();
if(!nullval($link)) {

//* Logic to extract info from the link goes here and it's added to $txt *//

/* End isset(vid) */
/* End function */
return $txt;

The output expected is an array, example:

$video['description'] ='';
$video['title'] ='';
$video['thumbnail'] ='';
$video['duration'] ='';
$video['tags'] ='';

The function gets hooked to the filter EmbedDetails

add_filter('EmbedDetails', 'DetailsnewSourceName');

Now you will be returning video details on the second submission page.



  • khuong says:

    please show me by video?

  • monu says:

    I want to buy this phpvibe theme I have seen phpvibe theme .this is good php theme but one Issue i seen in it. if any user or new person upload any video from youtube embed code them video didn’t plays sowing some error. so please check and make sure user can upload videos after that i will able to buy this theme

  • Ben says:

    Hi Vibe,
    How can i edit for theme support multi source video per a post?
    postid: 1
    title: abc
    source : [,,]
    So clients can choose which best site they can watch. or sometimes option 1 die they will watch the option 2.
    can i do that?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.