この関数を使用して画像の onLoad と onResize のサイズを変更するスクリプトがあります。
/**
* Calculates the display width of an image depending on its display height when it is resized.
* @param displayHeight the resized height of the image
* @param originalHeight the original height of the image
* @param originalWidth the original width of the image
* @return the display width
*/
function getDisplayWidth(displayHeight, originalHeight, originalWidth){
var ratio = originalHeight/displayHeight,
res = Math.round(originalWidth/ratio) || 1000;
return res;
}
..しかし、画像の高さが800pxを超えないようにしたいのですが、実際には800×530pxのサイズに固定することもできます。に固定値を返そうとしましたres
が、うまくいかないようです。
ありがとう!