RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Embed uStream Video With PHP or WordPress Shortcode

Embed uStream Video With PHP or WordPress Shortcode

Ustream is a company that provides video streaming services to more than 80 million viewers and broadcasters. Founded in 2007, it's now one of the most frequented websites for live or streaming video. This post will show you how to render responsive uStream videos into your WordPress post or page with shortcode. There's a PHP function for use outside of WordPress.

The Result

Shortcode of [ustream v="40478440"] (just the video ID), [ustream v="https://www.ustream.tv/recorded/40478440"] (the video ULR), or the actual embed URL of [ustream v="https://www.ustream.tv/embed/recorded/40478440"], all render the following into your WordPress website.

Shortcode Attributes

v

As stated, v is virtually any URL that references a particular video. It's best to use just the video ID since we strip all other characters from the URL string (regardless of how it's formatted) before rebuilding it.

width

The width in the shortcode function should be adjusted so that the video container fits nicely into the content area of your own website.

height

The height will automatically be scaled based on the width. The option to define the height for each video remains.

color

The color of the player controls can be set to red, green, pink, orange, or left blank (which renders the default uStream blue). These colors match up with the options available if you were to directly copy the messy embed code. Use like ustream v="40478440" color="red".

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

1
<?php 
2
/*
3
 Embed uStream Video With PHP or WordPress Shortcode
4
 http://www.beliefmedia.com/ustream-wordpress
5
 Permitted colors are red, green, pink & orange, or left blank for blue (default)
6
*/
7
 
8
function beliefmedia_ustream_video($atts) {
9
 extract(shortcode_atts(array(
10
  'v'  => '',
11
  'width'  => '560',
12
  'height'  => '',
13
  'color'  => ''
14
 ), $atts));
15
 
16
  /* If no height is defined... */
17
  if (!$height) $height = round($width / 1.58);
18
 
19
   /* Whether embed or video URL, we'll get video ID */
20
   if (strpos($v,'http') !== false) {
21
    $id = substr($v, strrpos($v, '/') + 1);
22
    $v = trim($id);
23
   }
24
 
25
   /* Color html for embed code */
26
   switch ($color) {
27
    case "red":
28
     $c = 'ff3d23';
29
     break;
30
    case "green":
31
     $c = '85a901';
32
     break;
33
    case "pink":
34
     $c = 'e166b7';
35
     break;
36
    case "orange":
37
     $c = 'ff720a';
38
     break;
39
   }
40
 
41
   $style = '
42
<style scoped>
43
    .embed-container {
44
      position: relative;
45
      padding-bottom: ' . round(($height / $width) * 100) . '%;
46
      height: 0;
47
      overflow: hidden;
48
      max-width: ' . $width . 'px;
49
      margin: 0px auto;
50
    }
51
 
52
    .embed-container iframe {
53
      position: absolute;
54
      top: 0px;
55
      left: 0px;
56
      width: 100%;
57
      height: 100%;
58
      padding-bottom: 0;
59
    }</style>
60
 
61
';
62
 
63
  /* Build iframe */
64
  $return .= '<iframe width="' . $width . '" height="' . $height . '" src="https://www.ustream.tv/embed/recorded/' . $v . '?';
65
  if ($color) $return .= 'ub=' . $c . '&lc=' . $c . '&oc=ffffff&uc=ffffff&';
66
  $return .= 'v=3&wmode=direct" scrolling="no" frameborder="0"></iframe>';
67
 
68
 /* Responsive iframe */
69
 return '<div>' . $style . '<div class="embed-container">' . $return . '</div>
70
</div>';
71
}
72
add_shortcode('ustream', 'beliefmedia_ustream_video');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Download


Title: Embed uStream Video in WordPress (WordPress Plugin)
Description: Embed responsive uStream videos in WordPress with shortcode.
  Download • Version 0.2, 1.9K, zip, Category: WordPress Plugins (General)
WordPress Shortcodes, (1.0K)    

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment