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
/**
 * Event handler to protect src image urls.
 *
 * @param string $url
 * @param SrcImage $src_image
 * @return string
 */
function get_src_image_url_protection_handler($url, $src_image)
{
    return get_action_url($src_image->id, $src_image->is_original() ? 'e' : 'r', false);
}