示例#1
0
function rip_flickr_data($record)
{
    $lics = flickr_get_licenses();
    // echo '<pre>'; print_r($lics);  die();
    $title = $record['title'];
    $license = $lics[$record['license']];
    // echo '<pre>';print_r($license); die();
    $description = '';
    $sizes = flickr_request('flickr.photos.getSizes', array('photo_id' => $record['id']));
    $sizes = $sizes['sizes'];
    $thumbs = array();
    // w:h => array( file, file, file)
    $largest = array(0, '', 0, 0);
    $smallest = array(3000 * 3000, '', 3000, 3000);
    // Ok, hacky, sosumi
    foreach ($sizes['size'] as $thumb) {
        if ($thumb['label'] == 'Square') {
            continue;
        }
        // These are a little smaller than default
        if (!isset($thumbs["{$thumb['width']}x{$thumb['height']}"])) {
            $thumbs["{$thumb['width']}x{$thumb['height']}"] = array();
            if ($thumb['width'] * $thumb['height'] > $largest[0]) {
                $largest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'], $thumb['height']);
            }
            if ($thumb['width'] * $thumb['height'] < $smallest[0]) {
                $smallest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'], $thumb['height']);
            }
        }
        $thumbs["{$thumb['width']}x{$thumb['height']}"][] = $thumb;
    }
    // Find the main image link
    $mainImage = $thumbs[$largest[1]];
    $mainImage = array_pop($mainImage);
    // Find the thumb image link
    $thumbImage = $thumbs[$smallest[1]];
    $thumbImage = array_pop($thumbImage);
    // Final image to pass to manager (use query param to record the embed url)
    $combinedImage = $mainImage['source'] . '?x-flickr-photo=' . rawurlencode($record['id']) . '&x-lic=' . rawurlencode($license['x-id']) . '&x-uid=' . rawurlencode($record['owner']) . '&x-by=' . rawurlencode($record['ownername']) . '&x-tn=' . rawurlencode($thumbImage['source']);
    return array('title' => $title, 'description' => $description, 'dimensions' => "{$mainImage['width']}x{$mainImage['height']}", 'license' => $license, 'mainImage' => $mainImage['source'], 'thumbImage' => $thumbImage['source'], 'combinedImage' => $combinedImage, 'smallest' => $smallest, 'largest' => $largest, 'thumbs' => $thumbs);
}
示例#2
0
function flickr_is_default_license($licIDs)
{
    global $IMConfig;
    $lics = flickr_get_licenses();
    foreach ($lics as $lic) {
        if ($lic['url'] == $IMConfig['Flickr']['Default License']) {
            if (in_array($lic['id'], explode(',', $licIDs))) {
                return TRUE;
            }
        }
    }
    return FALSE;
}