0

画像のサイズを変更してから、FancyBoxに入れようとしています。私は別のページでそれを行うことができました、そして私はそれを別のページに模倣しました、そして機能は動作しません。

これは機能しないページのコードです(幅と高さの2つの変数があり、resizeImage関数は「グローバル;」を宣言することでそれらにアクセスしますが、機能しません)。

*注-両方のページ:機能しているページと機能していないページが同じフォルダーにあるため、すべてのパスが同じです。

include("Include/FunctionsPHP.php"); //Includes the ResizeImage functions
$outputHeight;
$outputWidth; 

$index=$row["nIndex"];
$picture="products/pictures/{$row["sPicture"]}";

ResizeImage(450,400,$picture);

そしてこれはインクルードファイルです:

function ResizeImage($maxWidth,$maxHeight,$picture)
{
    GLOBAL $outputWidth;
    GLOBAL $outputHeight;
    $size = getimagesize($picture);

    if ($size) {
        $imageWidth  = $size[0];
        $imageHeight = $size[1];
        $wRatio = $imageWidth / $maxWidth;
        $hRatio = $imageHeight / $maxHeight;
        $maxRatio = max($wRatio, $hRatio);
        $outputWidth = $imageWidth / $maxRatio;
        $outputHeight = $imageHeight / $maxRatio;
        echo $outputHeight."\t";
        echo $outputWidth;
    }
}
?>

何か案は?

4

1 に答える 1

4

2つの変数をパラメーターとして関数に追加します。

于 2012-07-05T09:36:23.577 に答える