adding code to integrated video tuts

If you look at this thread; https://premium.wpmudev.org/forums/topic/add-custom-videos-to-integrated-video-tutorials-plugin?replies=17#post-1281395

there is a code snippet there that I added to my functions file;

1: Can I sort this somehow so I get "my category" as the first column when viewing the videoes?

2: How can I add a series of videoes? I tried duplicating the part `add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
if ( 'myvid' == $slug ) {
$video_html = '<iframe width="640" height="480" src="https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0&controls=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
}

return $video_html;
}, 10, 2);

and changing the youtube video number, but that did not work

2: Can I use other sources like Vimeo, Google Drive etc to host my videoes?

  • Ivan

    Hi Hakonzen !

    1: You can replace this part as

    add_filter('wpmudev_vids_categories', function( $video_cats ) {
    	//add to other category
    	$video_cats[ 'other' ][ 'list' ][] = 'myvid';
    
    	//create my own category
    	$new_cat = array( 'mine' => array(
    		'name' => 'My Category',
    		'list' => array( 'myvid' )
    	));
    	$video_cats = $new_cat + $video_cats;
    
    	return $video_cats;
    });

    2: You can replace this part of code $video_html = to this one $video_html .= and it will work. Also, you can create only one function for wpmudev_vids_embed_html filter and add several videos there. For instance,

    add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
    	if ( 'myvid' == $slug ) {
    		$video_html = '<iframe src="https://player.vimeo.com/video/238096496" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
    		$video_html .= '<iframe src="https://drive.google.com/file/d/test_test/preview" width="640" height="480"></iframe>';
    	}
    
    	return $video_html;
    }, 10, 2);

    2: Yes, of course. As you can see I provided some examples in the previous snippet. For getting code for Google Drive Videos, you can read here - http://blogs.acu.edu/adamscenter/2015/01/20/how-to-embed-google-drive-videos/ For vimeo videos, you can hit Share link on video and copy this code

    With best regards,
    Ivan.

  • Hakonzen

    Thanks Ash (and @Ivan)

    I have sucsessfully added the mu-plugins folder and the .php file so I can find it in the Videotutorials tab now, but the video I linked in the .php file is not showing up. Did I mess ujp the code somehow? This is what I got:

    `<?php

    add_filter('wpmudev_vids_categories', function( $video_cats ) {
    //add to other category
    $video_cats[ 'other' ][ 'list' ][] = 'myvid';

    //create my own category
    $new_cat = array( 'mine' => array(
    'name' => 'Din nettside',
    'list' => array( 'myvid' )
    ));
    $video_cats = $new_cat + $video_cats;

    return $video_cats;
    });

    add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
    if ( 'myvid' == $slug ) {
    $video_html = '<iframe width="560" height="315" src="https://www.youtube.com/embed/YaeWagDRhvE" frameborder="0" allowfullscreen></iframe>';
    }

    return $video_html;
    }, 10, 2);

  • Hakonzen

    Hi Ivan
    I still find this a bit difficult/buggy

    I have set the file like this;

    <?php
    
     add_filter('wpmudev_vids_categories', function( $video_cats ) {
    	//add to other category
    	$video_cats[ 'other' ][ 'list' ][] = 'myvid';
    
    	//create my own category
    	$new_cat = array( 'mine' => array(
    		'name' => 'Din nettside',
    		'list' => array( 'myvid' )
    	));
    	$video_cats = $new_cat + $video_cats;
    
    	return $video_cats;
    });
    
    add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
    	if ( 'myvid' == $slug ) {
    		$video_html = '<iframe width="560" height="315" src="https://www.youtube.com/embed/YaeWagDRhvE" frameborder="0" allowfullscreen></iframe>';
            $video_html = '<script src="https://fast.wistia.com/embed/medias/vaf6s4sknh.jsonp" async></script><script src="https://fast.wistia.com/assets/external/E-v1.js" async></script><div class="wistia_responsive_padding" style="padding:63.13% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_vaf6s4sknh videoFoam=true" style="height:100%;width:100%"> </div></div></div>';
    			}
    
    	return $video_html;
    }, 10, 2);
    
     add_filter('wpmudev_vids_list', function( $video_list ) {
    	$video_list[ 'myvid' ] = 'Divi-byggeren';
    	return $video_list;
    });
    
    and it only returns the first video (see att. image), the one with the youtube iframe. The  embed code from wistia doesn

    t work. I also tried this; $video_html = '<iframe src="https://hakonzen.wistia.com/medias/vaf6s4sknh?embedType=async&videoFoam=true&videoWidth=640';
    as an alternative for the wistia video.

    The video that is displaying, is actually being desplayed on two different places, the column "Din nettside" and the column "User, tools and settings", see the att. image again

    Also, i tried the code `add_filter('wpmudev_vids_list', function( $video_list ) {
    $video_list[ 'myvid' ] = 'My Favorite Vid';
    $video_list[ 'myvid' ] = 'My Favorite Vid' 2;
    $video_list[ 'myvid' ] = 'My Favorite Vid' 3;
    return $video_list;
    });
    but that gave me the white screen of death to the page

    Pleace advice me how to get this working proper...

    Image; https://www.dropbox.com/s/rddkrmqf88adlq4/videotuts_3.PNG?dl=0

  • Ivan

    Hi Hakonzen !

    Regarding your last code - you should remove two lines with $video_html and add one line with two videos
    $video_html = '<iframe width="560" height="315" src="https://www.youtube.com/embed/YaeWagDRhvE" frameborder="0" allowfullscreen></iframe><script src="https://fast.wistia.com/embed/medias/vaf6s4sknh.jsonp" async></script><script src="https://fast.wistia.com/assets/external/E-v1.js" async></script><div class="wistia_responsive_padding" style="padding:63.13% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_vaf6s4sknh videoFoam=true" style="height:100%;width:100%"> </div></div></div>';
    I tested on my site - it works.

    desplayed on two different places

    $video_cats[ 'other' ][ 'list' ][] = 'myvid';
    this line adds link to "User, tools and settings" - you can just delete it.

    This snippet will work for several blocks and links

    <?php
    add_filter('wpmudev_vids_categories', function( $video_cats ) {
    	//create my own category
    	$new_cat = array(
    		'first' => array(
    			'name' => 'First Block',
    			'list' => array( 'link_1', 'link_2', 'link_3' )
    		),
    		'second' => array(
    			'name' => 'Second Block',
    			'list' => array( 'link_4', 'link_5', 'link_6' )
    		),
    		'third' => array(
    			'name' => 'Third Block',
    			'list' => array( 'link_7', 'link_8', 'link_9' )
    		),
    	);
    	$video_cats = $new_cat + $video_cats;
    
    	return $video_cats;
    });
    
    add_filter('wpmudev_vids_embed_html', function( $video_html, $slug ) {
    	switch ( $slug ) {
    		case 'link_1':
    			$video_html = 'iframe 1';
    			break;
    		case 'link_2':
    			$video_html = 'iframe 2';
    			break;
    		case 'link_3':
    			$video_html = 'iframe 3';
    			break;
    		case 'link_4':
    			$video_html = 'iframe 4';
    			break;
    		case 'link_5':
    			$video_html = 'iframe 5';
    			break;
    		case 'link_6':
    			$video_html = 'iframe 6';
    			break;
    		case 'link_7':
    			$video_html = 'iframe 7';
    			break;
    		case 'link_8':
    			$video_html = 'iframe 8';
    			break;
    		case 'link_9':
    			$video_html = 'iframe 9';
    			break;
    	}
    
    	return $video_html;
    }, 10, 2);
    
     add_filter('wpmudev_vids_list', function( $video_list ) {
    	$video_list[ 'link_1' ] = 'Link 1';
    	$video_list[ 'link_2' ] = 'Link 2';
    	$video_list[ 'link_3' ] = 'Link 3';
    
    	$video_list[ 'link_4' ] = 'Link 4';
    	$video_list[ 'link_5' ] = 'Link 5';
    	$video_list[ 'link_6' ] = 'Link 6';
    
    	$video_list[ 'link_7' ] = 'Link 7';
    	$video_list[ 'link_8' ] = 'Link 8';
    	$video_list[ 'link_9' ] = 'Link 9';
    
    	return $video_list;
    });

    I hope it will be more clear for understanding. Let me know if you need our help again.

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.