Guest User

Modified to use Youtube iframe for individual videos

a guest
Dec 5th, 2011
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. // Filename: vipers-video-quicktags.php
  2. // In function shortcode_youtube()
  3. // Modified to use Youtube iframe for individual videos
  4.  
  5.     // Find this "Setup the parameters" in the funciton ...
  6.     $rel        = ( 1 == $atts['rel'] ) ? '1' : '0';
  7.     $fs         = ( 1 == $atts['fs'] ) ? '1' : '0';
  8.     $showsearch = ( 1 == $atts['showsearch'] ) ? '1' : '0';
  9.     $showinfo   = ( 1 == $atts['showinfo'] ) ? '1' : '0';
  10.  
  11.     // ADDED
  12.     $iframeurl = 'http://www.youtube.com/embed/' . $videoid . '?feature=oembed';
  13.     foreach ( array( 'fs', 'rel', 'showsearch', 'showinfo' ) as $attribute ) {
  14.         $iframeurl = add_query_arg( $attribute, $$attribute, $iframeurl );
  15.     }
  16.  
  17.     $objectid = $this->videoid('youtube');
  18.  
  19.     // Hack until this plugin properly supports iframe-based embeds
  20.     if ( ! empty( $iframe ) ) {
  21.         return '<iframe class="vvqbox vvqyoutube" width="' . esc_attr( $atts['width'] ) . '" height="' . esc_attr( $atts['height'] ) . '" src="'. esc_url( $iframe . '&rel=' . $rel . '&fs=' . $fs . '&showsearch=' . $showsearch . '&showinfo=' . $showinfo . $autoplay . $loop . $hd ) . '" frameborder="0" allowfullscreen></iframe>';
  22.     }
  23.  
  24.     $this->swfobjects[$objectid] = array(
  25.         'width' => $atts['width'],
  26.         'height' => $atts['height'],
  27.         'url' => 'http://www.youtube.com/' . $embedpath . $color1 . $color2 . $border . '&rel=' . $rel . '&fs=' . $fs . '&showsearch=' . $showsearch . '&showinfo=' . $showinfo . $autoplay . $loop . $hd,
  28.     );
  29.  
  30.     // MODIFIED
  31.     return '<span class="vvqbox vvqyoutube" style="width:' . $atts['width'] . 'px;"><span class="video-container"><iframe id="' . $objectid . '" src="' . esc_attr( $iframeurl ) . '" width="' . $atts['width'] . '" height="' . $atts['height'] . '" frameborder="0"><a href="' . $fallbacklink . '">' . $fallbackcontent . '</a></iframe></span></span>';
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment