function emimage_flickr_import in Embedded Media Field 6
This allows flickr photosets to be imported into nodes
File
- contrib/
emimage/ providers/ flickr.inc, line 46 - This include processes flickr.com image files for use by emfield.module.
Code
function emimage_flickr_import($url, $limit = 0, $page = 0) {
$codes = array();
// http://www.flickr.com/photos/nikkiana/sets/72157601948647678/
if (preg_match('@flickr\\.com/photos/([^/]*)/([^/]*)/([^/]*)/@i', $url, $matches)) {
$page++;
// flickr starts current page at 1
$codes['#matches'] = $matches;
$args = array(
'photoset_id' => $matches[3],
);
if ($limit) {
$args['per_page'] = $limit;
}
$args['page'] = $page;
$xml = emimage_flickr_request('flickr.photosets.getPhotos', $args);
$codes['#pages'] = $xml['photoset']['pages'];
$codes['#page'] = $xml['photoset']['page'] - 1;
$codes['#total'] = $xml['photoset']['total'];
$codes['#per_page'] = $xml['photoset']['per_page'];
$codes['#set'] = array();
foreach ($xml['photoset']['photo'] as $photo) {
$data = emimage_flickr_data(NULL, array(
'value' => $photo['id'],
));
$codes['#set'][] = array(
'#code' => $photo['id'],
'#title' => $photo['title'],
'#link' => emimage_flickr_embedded_link($photo['id'], $xml['photoset']['owner']),
'#thumb' => emimage_flickr_image_url($photo['id'], 100, 100, NULL, NULL, NULL),
'#body' => $data['description'],
'#tags' => $data['tags'],
);
}
/*
$data['owner'] = $xml['photo']['owner']['nsid'];
$data['title'] = $xml['photo']['title']['_content'];*/
}
return $codes;
}