商品詳細画面にて「Warning: getimagesize」が表示される問題の回避策

今回は、EC-CUBE 2.4.0 です。


商品詳細画面を表示すると、以下、表示されました。

Warning: getimagesize() [function.getimagesize]: Filename cannot beempty in /home/sodc/www/eccube-2.4.0/data/class/pages/products/LC_Page_Products_Detail.php on line 282


原因は、商品詳細画面にて使用する、商品の拡大画像が登録されていないから。
管理画面で商品の拡大画像を登録すれば、上記表示されません。


しかしながら、商品の拡大画像をいちいち登録していくのはナンセンスなので、ちょろっとソースを修正してい対応します。

# cd eccube/data/class/pages/products
# vi LC_Page_Products_Detail.php

// 以下をコメントアウト
Line 276
  // 拡大画像のウィンドウサイズをセット
  if (isset($this->arrFile["main_large_image"])) {
    $image_path = IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"]);
    } else {
      $image_path = "";
    }

    list($large_width, $large_height) = getimagesize($image_path);
    $this->tpl_large_width = $large_width + 60;
    $this->tpl_large_height = $large_height + 80;

Line 500
    // 拡大画像のウィンドウサイズをセット
    if (!empty($this->arrFile["main_large_image"])) {
      list($large_width, $large_height) = getimagesize(IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"]));
    }
    $this->tpl_large_width = isset($large_width) ? $large_width + 60 : 0;
    $this->tpl_large_height = isset($large_height) ? $large_height + 80 : 0;

これでWarningの表示はなくなります。


そんな感じで。


でわ。