コード例 #1
0
$new_img_width = $_GET['width'];
$new_img_height = $_GET['height'];
$img = null;
$img_remote = null;
if (function_exists("gd_info") && function_exists("imagecreatefromjpeg") && function_exists("imagecreatefromgif")) {
    $img_path = parse_url($img_src);
    $img_ext = pathinfo($img_path['path'], PATHINFO_EXTENSION);
    if (empty($img_ext)) {
        // dynamic image URL
        if (preg_match("|http://(.*?)/(.*)|", $img_src, $m)) {
            try {
                list(, $uf_server, $uf_path) = $m;
                $image_file = Storage::save($img_src, basename($uf_path), "critical", "image");
                if (!empty($image_file)) {
                    $stored_img = new StoredFile($image_file);
                    $img_src = $stored_img->getURL();
                    $img_path = parse_url($img_src);
                    $img_ext = pathinfo($img_path['path'], PATHINFO_EXTENSION);
                } else {
                    echo "invalid IMG url";
                    exit;
                }
            } catch (Exception $e) {
                $img = null;
            }
        }
    }
    if ($img_path['host'] == $_SERVER['SERVER_NAME']) {
        // image from local server
        $img_src = PA::resolveRelativePath('web' . $img_path['path']);
    }