Ticket #414 (closed バグ指摘: 修正済)
モバイル画像生成で高さの指定が不正になる
Reported by: | kakinaka | Owned by: | somebody |
---|---|---|---|
Priority: | 中 | Milestone: | EC-CUBE2.4.0 |
Component: | フロント | Version: | 2.4.0RC-2 |
Keywords: | Cc: | ||
修正済み: | yes |
Description
モバイル端末でモバイルページを閲覧すると、モバイル用の画像が自動生成されますが、
なぜか1つ目の画像の高さ情報を保持したままとなり、2枚目以降の画像が崩れる場合があります。
Change History
comment:1 Changed 14 years ago by Seasoft
- Version changed from 2.3.3 to 2.4.0RC-2
- Milestone changed from EC-CUBE2.3.4 to EC-CUBE2.4.0
comment:2 Changed 14 years ago by Seasoft
Masashige 様から、改善方法の投稿がありました。
記事からすると、width の方も改善の余地があるのかもしれません。(もしや、勝手に拡大されるとか??)
以下、記事抜粋です。
if (is_null($this->outputImageHeight)) { $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth); }
image_converter.incの33~35行目ですね。2枚目以降の呼び出しで1枚目の情報が残ってしまうようで、ここがスルーされます。
面倒だったので(えー!?)33、35行目をコメントアウトして対応しました。どうせキャッシュされるし、納期も無茶だし、まぁいっか!みたいな。そんなんしてたらwidth固定とかも直したくなるし…。
comment:3 Changed 14 years ago by kishik
33行目以降を
if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth);
}
から
if (is_null($this->outputImageHeight)) {
$height_was_null = TRUE;
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth);
} else {
$height_was_null = FALSE;
}
に変えて、
(変更前の)118行目に
if ($height_was_null) {
$this->outputImageHeigh = NULL;
}
を挿入すれば、元のロジックを崩さなくていいはずです。
comment:4 follow-up: ↓ 5 Changed 14 years ago by Seasoft
QAZU 様から、Width を含めた解決方法の投稿がありました。
ただし、320px で固定しているので、この部分は $this->outputImageWidth を使用する(要 NULL チェック?)のが適切な気がします。
comment:5 in reply to: ↑ 4 Changed 14 years ago by kishik
掲示板にも書きましたが、
QAZUさんの投稿分では解決できません。
使用している画像の横幅が320px以下だと
解決しているように見えるだけのはずです。
コメント3つ目に書いた方法が正しいはずです。
comment:6 Changed 14 years ago by kishik
画像が最大携帯画像サイズ以下の場合には
そのままの大きさのものを表示するように
コードを以下のものに訂正します。
現在のEC-CUBEは横幅しか考慮されていませんが、
高さも制限に入れるようにした場合でも対応できるようにしたつもりです。
if (is_null($this->outputImageHeight)) { $height_was_null = TRUE; $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth); } else { $height_was_null = FALSE; } if ($inputImageWidth <= $this->outputImageWidth) { if ($inputImageHeight <= $this->outputImageHeight) { $this->outputImageWidth = $inputImageWidth; $this->outputImageHeight = $inputImageHeight; } else { $this->outputImageWidth = $inputImageWidth * ($this->outputImageHeight / $inputImageHeight); } else { if ($inputImageHeight <= $this->outputImageHeight) { $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth); } else { if ($this->outputImageWidth / $inputImageWidth < $this->outputImageHeight / $inputImageHeight) { $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth); } else { $this->outputImageWidth = $inputImageWidth * ($this->outputImageHeight / $inputImageHeight); } } }
comment:7 Changed 14 years ago by kishik
携帯各端末での画像高さを指定しても縦横比を崩さずに
最適な大きさにリサイズされるようになったはずなので、
/data/class/SC_MobileImage.php
の60行目に
$imageHeight = $data[4];
を追加して、(追加前の)86行目に
$imageConverter->setImageHeight($imageHeight);
も追加すれば、
/data/include/mobile_image_map_*.csv
が携帯サイトでの(縦横を含めた)最大画像サイズのデータを表すようになり、
ユーザーの意図する動作に近くなると思います。
2.4.0での導入をご検討ください。
comment:8 Changed 14 years ago by kishik
追記です。
その場合、
/data/include/image_converter.inc
の128行目に
function setImageHeight($imageHeight) { $this->outputImageHeight = $imageHeight; }
の挿入も必要でした。
確認不足失礼しました。
comment:9 Changed 14 years ago by kajiwara
本件、いろいろご調査いただきありがとうございます。
kishik様の修正方法にて修正させていただきました。
(r18006 にて対応いたしました。)
不具合など特にないようでしたら2.4.0正式版に含めたいと思います。
よろしくお願いいたします。
comment:10 Changed 14 years ago by kishik
2009/05/12 12:15:28
で記述している、
(変更前の)118行目に
if ($height_was_null) {
$this->outputImageHeigh = NULL;
}
の処理が足りないので、
これも追加お願いします。
comment:11 Changed 14 years ago by kajiwara
r18009 kishik様のご指摘通り、不足分のコードを追加させていただきました。
comment:13 Changed 14 years ago by Seasoft
- Status changed from closed to reopened
- Resolution 修正済 deleted
追記したソースの整形が open_trac/wiki/EC-CUBE標準規約 に従わず、TAB & 2SP という不可解な状態になっています。
抜粋
インデントは, 半角スペース4文字を使用し, タブは使用しない.
元々が TAB になっているようですが、これも 4SP に変換しても良い気がします。秀丸エディタなら、TAB → SP の変換はスマートに可能です。参考まで。
comment:14 follow-up: ↓ 15 Changed 14 years ago by kajiwara
comment:15 in reply to: ↑ 14 Changed 14 years ago by Seasoft
- Status changed from reopened to closed
- Resolution set to 修正済
インデントの修正を確認しました。
フォーラムにて QAZU 様から実記での詳細な報告があり、当方ではシミュレータでも再現を確認しました。
http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=3905&forum=8
QAZU 様は下記バージョンで発現しているようです。
当方では下記バージョンで再現を確認しました。