HERE;
$i++;
}
}
$images_width = $uwidth_sum + ( count($images) * 5 ) + 30;
break;
case 'flickr':
require_once ABSPATH . WPINC . '/class-snoopy.php';
function flickr_api_call($method, $params = '') {
$api_key = '7cd7b7dea9c9d3069caf99d12471008e'; // An API key reserved for WordPress
$searchurl = 'http://www.flickr.com/services/rest/?method=' . $method . '&api_key=' . $api_key . '&' . $params;
$client = new Snoopy();
$client->agent = 'WordPress/Flickr Browser';
$client->read_timeout = 2;
$client->use_gzip = true;
@$client->fetch($searchurl);
return $client->results;
}
// How many images do we show? How many do we query?
$num = 5;
$double = $num * 2;
$flickr_user_id = get_user_option('flickr_userid');
if($flickr_user_id == '') {
$flickr_username = get_user_option('flickr_username');
$user_xml = flickr_api_call('flickr.people.findByUsername', "username={$flickr_username}");
if(preg_match('/nsid="(.*?)">/', $user_xml, $matches)) {
$flickr_user_id = $matches[1];
}
else die("Failed to find Flickr ID for '$flickr_username'"); // Oh, dear - no Flickr user_id!
// Store the found Flickr user_id in usermeta...
// Don't forget on the options page to update the user_id along with the username!
update_user_option($current_user->id, 'flickr_userid', $flickr_user_id, true);
}
// Fetch photo list from Flickr
$ustart = $start + 1;
//$photos_xml = flickr_api_call('flickr.photos.search', array('per_page' => $num, 'user_id' => $flickr_user_id));
if($flickrtag == '') {
$all = '0';
$photos_xml = flickr_api_call('flickr.people.getPublicPhotos', "per_page={$num}&user_id={$flickr_user_id}&page={$ustart}");
}
else {
$photos_xml = flickr_api_call('flickr.photos.search', "per_page={$num}&user_id={$flickr_user_id}&page={$ustart}&tags={$flickrtag}");
$all = '0&flickrtag=' . $flickrtag;
}
//echo "" . htmlentities($photos_xml) . "
"; // Displays the XML returned by Flickr for the photo list
//Get Page Count
preg_match('/ 0) $back = $start - 1; else $back = false;
if($last != '') {
$photos_xml = flickr_api_call('flickr.people.getPublicPhotos', "per_page={$num}&user_id={$flickr_user_id}&page={$page_count}");
$back = $page_count -1;
$next = false;
}
//Get Photos
preg_match_all('//', $photos_xml, $matches, PREG_SET_ORDER);
foreach($matches as $match) {
$img['post_title'] = $match[4];
$sizes_xml = flickr_api_call('flickr.photos.getSizes', "photo_id={$match[1]}");
preg_match_all('//', $sizes_xml, $sizes, PREG_SET_ORDER);
$max_size = '';
foreach($sizes as $size) {
$img_size[$size[1]]['width'] = $size[2];
$img_size[$size[1]]['height'] = $size[3];
$img_size[$size[1]]['url'] = $size[4];
if($max_size == '' || $img_size[$size[1]]['width'] > $img_size[$max_size]['width']) {
$max_size = $size[1];
}
}
$images[] = array(
'post_title' => $match[4],
'thumbnail' => $img_size['Thumbnail']['url'],
'full' => $img_size[$max_size]['url'],
'href' => "http://flickr.com/photos/{$flickr_user_id}/{$match[1]}/",
'width' => $img_size['Thumbnail']['width'],
'height' => $img_size['Thumbnail']['height'],
'size_info' => $img_size,
);
}
$current_flickr = ' class="current"';
$__use_size = __('Use %s');
$__close = __('CLOSE');
$images_script .= "var flickr_src = new Array();\n";
$i=0;
foreach($images as $image) {
list($uwidth, $uheight) = get_udims($image['width'], $image['height']);
$xpadding = (128 - $uwidth) / 2;
$ypadding = (96 - $uheight) / 2;
$height_width = 'height="'.$uheight.'" width="'.$uwidth.'"';
$images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n";
$images_html .= "
";
$i++;
}
$images_width = ( count($images) * 133 ) + 5;
break;
default:
die('This script was not meant to be called directly.');
}
?>
>>
>|
>>
>|
Duplicated filenames will be numbered (photo.jpg, photo1.jpg, etc.)