Example #1
0
/**
 * returns an array map of urls (thumb/element) for image_row - to be returned
 * in a standard way by different web service methods
 */
function ws_std_get_urls($image_row)
{
    $ret = array();
    $ret['page_url'] = make_picture_url(array('image_id' => $image_row['id'], 'image_file' => $image_row['file']));
    $src_image = new SrcImage($image_row);
    if ($src_image->is_original()) {
        // we have a photo
        global $user;
        if ($user['enabled_high']) {
            $ret['element_url'] = $src_image->get_url();
        }
    } else {
        $ret['element_url'] = get_element_url($image_row);
    }
    $derivatives = DerivativeImage::get_all($src_image);
    $derivatives_arr = array();
    foreach ($derivatives as $type => $derivative) {
        $size = $derivative->get_size();
        $size != null or $size = array(null, null);
        $derivatives_arr[$type] = array('url' => $derivative->get_url(), 'width' => $size[0], 'height' => $size[1]);
    }
    $ret['derivatives'] = $derivatives_arr;
    return $ret;
}
Example #2
0
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
    if (isset($page['previous_item']) and $row['id'] == $page['previous_item']) {
        $i = 'previous';
    } elseif (isset($page['next_item']) and $row['id'] == $page['next_item']) {
        $i = 'next';
    } elseif (isset($page['first_item']) and $row['id'] == $page['first_item']) {
        $i = 'first';
    } elseif (isset($page['last_item']) and $row['id'] == $page['last_item']) {
        $i = 'last';
    } else {
        $i = 'current';
    }
    $row['src_image'] = new SrcImage($row);
    $row['derivatives'] = DerivativeImage::get_all($row['src_image']);
    if ($i == 'current') {
        $row['element_path'] = get_element_path($row);
        if ($row['src_image']->is_original()) {
            // we have a photo
            if ($user['enabled_high'] == 'true') {
                $row['element_url'] = $row['src_image']->get_url();
                $row['download_url'] = get_action_url($row['id'], 'e', true);
            }
        } else {
            // not a pic - need download link
            $row['download_url'] = $row['element_url'] = get_element_url($row);
        }
    }
    $row['url'] = duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start'));
    $picture[$i] = $row;