Amazon Web Services の輸入盤の画像 URL 問題を解消しつつ、さらに画像がなかったら no image の画像を返し、かつサイズを適当にあわせる javascript。
function resizeAWSImage(img) {
var reload;
if (img.width == 1) {
if (img.src.indexOf('.09.') > -1) {
img.src = img.src.replace('.09.','.01.');
reload = 1;
} else {
img.src = 'http://images-jp.amazon.com/images/G/09/x-locale/detail/thumb-no-image.gif';
reload = 1;
}
}
if (reload) return;
if (img.width > img.height) {
img.width = 30;
} else {
img.height = 30;
}
}
<img src="[% item.ImageUrlMedium %]" onLoad="resizeAWSImage(this)" /> みたいにして使う。
最後の img.width と img.height とか no-image のパスとかは適当に変える必要アリです。