○URLパス名分岐
/ が含まれる
var pathname = location.pathname; if ( pathname == '/PATHNAME' ) { // function }
○比率から計算して切り取り
cssでoverflow:hiddenを入れとく
var ratio = 0.65; // 80 x 120 var wrapperWidth = $('.wrapper').width(); var thumbWidth = Math.floor( wrapperWidth * 0.26 ); var thumbHeight = Math.floor( thumbWidth * ratio ); $('.thumb').css({'height':thumbHeight+'px'});
○縦長横長判定
横長画像 ‘landscape’ クラスをつける
$('.thumb').each(function(){ var imageWidth = $('img' ,this).width(); var imageHeight = $('img' ,this).height(); if ( imageHeight < imageWidth ) { $('img' ,this).addClass('landscape'); } });