バージョン選択

フォーラム

メニュー

オンライン状況

38 人のユーザが現在オンラインです。 (21 人のユーザが フォーラム を参照しています。)
登録ユーザ: 1
ゲスト: 37
zakey もっと...

サイト内検索

バグ報告 > フロント機能 > モバイル用イメージの変換に関して

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
kishik
投稿日時: 2009/5/12 17:00
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
240pxというのはお使いの携帯端末に対応した(最大)画像幅ですね。
EC-CUBEの中に端末ごとのテーブルとして保持されています。
/data/include/mobile_image_map_docomo.csv
などに入っています。
最新の機種などはどれにもマッチせず、
最終行の値が使われます。

ところで、QAZUさんのコードでは
常に320px以下のものは元画像の大きさを使用するようになるので、
コードの後半は全く使われていません。
// 変換後の画像の高さが〜
以下の行は不要なはずです。
そして、
幅320px以上のものを使い始めるとまた不具合が起こります。

私がチケットに書いたものを以下に更新してみてください。


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);
    }
  }
}


これで意図した動作になるとともに、
将来の変更にも耐えうると思います。


-----
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
QAZU
投稿日時: 2009/5/13 10:21
対応状況: −−−
半人前
登録日: 2007/3/7
居住地:
投稿: 26
Re: モバイル用イメージの変換に関して
kishikさま

何度も有難うございます。

早速使わせていただきます。
kishik
投稿日時: 2009/5/13 10:38
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
もし不具合がありましたらご連絡ください。
チケットの方にも反映させますので。


-----
カスタマイズ承ります
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
QAZU
投稿日時: 2009/5/18 16:07
対応状況: −−−
半人前
登録日: 2007/3/7
居住地:
投稿: 26
Re: モバイル用イメージの変換に関して
kishikさま

プログラマーの方に、kishikさまのソースを渡して、
実際に検証してもらいました。
色々チェックしてもらった結果、下記のようなソースが返ってきました。
検証して、まとめたプログラムだそうです。
現状では、問題なく動いているので、恥ずかしながら、このソース内で行われている処理が個人的に理解できていない状態です・・・

data/include/image_converter.inc
[old]
// 変換後の画像の高さが指定されていない場合、変換後の画像の横幅から求める
if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}

============================================================
[new]

//変換の前画像の横幅が小さい場合画像のサイズそのまま使う
if($inputImageWidth <= $this->outputImageWidth){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = NULL;
}

// 変換後の画像の高さが指定されていない場合、変換後の画像の横幅から求める
if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}

mobile_image_map_[端末会社].csvによってサイズのsettingになるので
画像のサイズが大きい場合ファイルから呼んで来たサイズと比べて自動計算になるようになっています。
だからサイズが小さなイメージの場合もsettingされたサイズによって自動でイメージ変更になった後高さが計算されるので小さなサイズのイメージが自動変更されて大きくなってしまった現象がありました。

それでsettingされたサイズとイメージサイズを比べた後サイズが小さな場合に$this->outputImageWidthを変更
例えば [$this->outputImageWidth = 220]
1. 250*50 サイズの場合 = > 220*44
if($inputImageWidth <= $this->outputImageWidth){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = NULL;
}
//(250 <= 220)が違うので$this->outputImageWidth=220になります。

if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}
//$this->outputImageHeight = 50 * (220/250) の計算によって高さが44に変更されます。

2. 100*20 サイズの場合 = > 100*20
if($inputImageWidth <= $this->outputImageWidth){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = NULL;
}
//(100 <= 220)によって$this->outputImageWidth=100になります。

if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}
//$this->outputImageHeight = 20 * (100/100) の計算によって高さがそのまま20になります。

上のように変更されるので$this->outputImageWidthを変更してくれることだけでも解決可能です。
kishik
投稿日時: 2009/5/18 17:46
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
この論理だと(書かれているもの以外はないとして)、
250*50サイズの画像2枚「だけ」を1ページに含む場合、
うまく動作しないのではないでしょうか?
(表示は220で設定されていると仮定しています)
都度対処ですね。

高さ指定された場合も考慮したものを
チケットに登録して、先日ソースに取り込まれたので、
2.4.0からは正しく表示されると思いますよ。


-----
カスタマイズ承ります
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
« 1 2 (3)
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,638名です
総投稿数は109,889件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2311
5
umebius
2085
6
yuh
1819
7
h_tanaka
1635
8
red
1569
9
mcontact
1265
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.