Created
June 1, 2012 15:34
-
-
Save c4y/2852996 to your computer and use it in GitHub Desktop.
Youtube Channel einbinden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function youtube_feed_shortcode($atts) | |
{ | |
// Defaults: | |
extract(shortcode_atts(array( | |
'user' => 'flamadiddle86', // youtube user | |
'limit' => 5, // maximum number of videos | |
'height' => 385, // video height | |
'width' => 480 // video width | |
), $atts)); | |
$data = @json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/users/'.$user.'/uploads?alt=json'), TRUE); | |
$counter = 0; | |
$content = '<div class="youtubefeed">'; | |
foreach($data['feed']['entry'] as $vid) | |
{ | |
$url = $vid['media$group']['media$content'][0]['url']; | |
$title = $vid['title']['$t']; | |
$ycontent = $vid['content']['$t']; | |
$content.= '<object width="'.$width.'" height="'.$height.'">'. | |
'<param name="movie" value="'.$url.'"></param>'. | |
'<param name="allowFullScreen" value="true"></param>'. | |
'<param name="allowscriptaccess" value="always"></param>'. | |
'<embed src="'.$url.'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$width.'" height="'.$height.'"></embed></object>'. | |
'<div class="youtubetitle">'.$title.'</div>'. | |
'<div class="youtubecontent">'.$ycontent.'</div>'."\n"; | |
$counter++; | |
if($counter == $limit) | |
{ | |
break; | |
} | |
} | |
$content .= '</div>'; | |
return $content; | |
} | |
add_shortcode('youtubefeed', 'youtube_feed_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment