Skip to content

Commit

Permalink
update default thumbnail url
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougherty committed Sep 16, 2011
1 parent d449b79 commit 42b0b03
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
38 changes: 19 additions & 19 deletions simple-api/gallery/js-example.html
Expand Up @@ -3,71 +3,71 @@
<head>
<meta charset="utf-8">
<title>Vimeo Simple API Gallery Example</title>

<style>
#thumbs { overflow: auto; height: 298px; width: 300px; border: 1px solid #E7E7DE; padding: 0; float: left; }
#thumbs ul { list-style-type: none; margin: 0 10px 0; padding: 0 0 10px 0; }
#thumbs ul li { height: 75px; }
.thumb { border: 0; float: left; width: 100px; height: 75px; background: url(http://bitcast.vimeo.com/vimeo/thumbnails/defaults/default.75x100.jpg); margin-right: 10px; }

.thumb { border: 0; float: left; width: 100px; height: 75px; background: url(http://a.vimeocdn.com/thumbnails/defaults/default.75x100.jpg); margin-right: 10px; }

#embed { background-color: #E7E7DE; height: 280px; width: 504px; float: left; padding: 10px; }

#portrait { float: left; margin-right: 5px; max-width: 100px; }
#stats { clear: both; margin-bottom: 20px; }
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>

var apiEndpoint = 'http://vimeo.com/api/v2/';
var oEmbedEndpoint = 'http://vimeo.com/api/oembed.json'
var oEmbedCallback = 'switchVideo';
var videosCallback = 'setupGallery';
var vimeoUsername = 'brad';

// Get the user's videos
$(document).ready(function() {
$.getScript(apiEndpoint + vimeoUsername + '/videos.json?callback=' + videosCallback);
});

function getVideo(url) {
$.getScript(oEmbedEndpoint + '?url=' + url + '&width=504&height=280&callback=' + oEmbedCallback);
}

function setupGallery(videos) {

// Set the user's thumbnail and the page title
$('#stats').prepend('<img id="portrait" src="' + videos[0].user_portrait_medium + '" />');
$('#stats h2').text(videos[0].user_name + "'s Videos");

// Load the first video
getVideo(videos[0].url);

// Add the videos to the gallery
for (var i = 0; i < videos.length; i++) {
var html = '<li><a href="' + videos[i].url + '"><img src="' + videos[i].thumbnail_medium + '" class="thumb" />';
html += '<p>' + videos[i].title + '</p></a></li>';
$('#thumbs ul').append(html);
}

// Switch to the video when a thumbnail is clicked
$('#thumbs a').click(function(event) {
event.preventDefault();
getVideo(this.href);
return false;
});

}

function switchVideo(video) {
$('#embed').html(unescape(video.html));
}

</script>
</head>
<body>

<h1>Vimeo Simple API Gallery Example</h1>
<div id="stats">
<h2></h2>
Expand All @@ -79,6 +79,6 @@ <h2></h2>
<ul></ul>
</div>
</div>

</body>
</html>
66 changes: 33 additions & 33 deletions simple-api/gallery/php-example.php
Expand Up @@ -14,59 +14,59 @@ function curl_get($url) {
}

if ($_GET['album']) {

// Get the album
$album_id = $_GET['album'];

// Load the videos and info
$videos = simplexml_load_string(curl_get($api_endpoint . 'album/' . $album_id . '/videos.xml'));
$info = simplexml_load_string(curl_get($api_endpoint . 'album/' . $album_id . '/info.xml'));

// Thumbnail and title
$image = $info->album->thumbnail;
$title = $info->album->title;

}
else if ($_GET['group']) {

// Get the group
$group_id = $_GET['group'];

// Load the videos and info
$videos = simplexml_load_string(curl_get($api_endpoint . 'group/' . $group_id . '/videos.xml'));
$info = simplexml_load_string(curl_get($api_endpoint . 'group/' . $group_id . '/info.xml'));

// Thumbnail and title
$image = $info->group->thumbnail;
$title = $info->group->name;

}
else if ($_GET['channel']) {

// Get the channel
$channel_id = $_GET['channel'];

// Load the videos and info
$videos = simplexml_load_string(curl_get($api_endpoint . 'channel/' . $channel_id . '/videos.xml'));
$info = simplexml_load_string(curl_get($api_endpoint . 'channel/' . $channel_id . '/info.xml'));

// Thumbnail and title
$image = null;
$title = $info->channel->name;

}
else {

// Change this to your username to load in your videos
$vimeo_user_name = ($_GET['user']) ? $_GET['user'] : 'brad';

// Load the user's videos
$videos = simplexml_load_string(curl_get($api_endpoint.$vimeo_user_name . '/videos.xml'));

// Thumbnail and title
$image = $videos->video[0]->user_portrait_medium;
$title = $videos->video[0]->user_name . "'s Videos";

}

?>
Expand All @@ -75,41 +75,41 @@ function curl_get($url) {
<head>
<meta charset="utf-8">
<title>Vimeo Simple API Gallery Example</title>

<style>
#thumbs { overflow: auto; height: 298px; width: 300px; border: 1px solid #E7E7DE; padding: 0; float: left; }
#thumbs ul { list-style-type: none; margin: 0 10px 0; padding: 0 0 10px 0; }
#thumbs ul li { height: 75px; }
.thumb { border: 0; float: left; width: 100px; height: 75px; background: url(http://bitcast.vimeo.com/vimeo/thumbnails/defaults/default.75x100.jpg); margin-right: 10px; }

.thumb { border: 0; float: left; width: 100px; height: 75px; background: url(http://a.vimeocdn.com/thumbnails/defaults/default.75x100.jpg); margin-right: 10px; }

#embed { background-color: #E7E7DE; height: 280px; width: 504px; float: left; padding: 10px; }

#portrait { float: left; margin-right: 5px; max-width: 100px; }
#stats { clear: both; margin-bottom: 20px; }
</style>

<script>

// Tell Vimeo what function to call
var oEmbedCallback = 'embedVideo';

// Set up the URL
var oEmbedUrl = 'http://vimeo.com/api/oembed.json';

// Load the first one in automatically?
var loadFirst = true;

// This function puts the video on the page
function embedVideo(video) {
var videoEmbedCode = video.html;
document.getElementById('embed').innerHTML = unescape(videoEmbedCode);
}

// This function runs when the page loads and adds click events to the links
function init() {
var links = document.getElementById('thumbs').getElementsByTagName('a');

for (var i = 0; i < links.length; i++) {
// Load a video using oEmbed when you click on a thumb
if (document.addEventListener) {
Expand All @@ -128,27 +128,27 @@ function init() {
});
}
}

// Load in the first video
if (loadFirst) {
loadScript(oEmbedUrl + '?url=' + links[0].href + '&height=280&width=504&callback=' + oEmbedCallback);
}
}

// This function loads the data from Vimeo
function loadScript(url) {
var js = document.createElement('script');
js.setAttribute('src', url);
document.getElementsByTagName('head').item(0).appendChild(js);
}

// Call our init function when the page loads
window.onload = init;

</script>
</head>
<body>

<h1>Vimeo Simple API Gallery Example</h1>
<div id="stats">
<img id="portrait" src="<?php echo $image ?>" />
Expand All @@ -170,6 +170,6 @@ function loadScript(url) {
</ul>
</div>
</div>

</body>
</html>

0 comments on commit 42b0b03

Please sign in to comment.