jQuery(document).ready(function($){ $('img.am2_list_img').one('load', function() { // Get on screen image var screenImage = $(this); // Create new offscreen image to test var theImage = new Image(); theImage.src = screenImage.attr("src"); // Get accurate measurements from that. var imageWidth = theImage.width; var imageHeight = theImage.height; /*console.log(theImage); console.log(imageWidth); console.log(imageHeight); console.log("-----");*/ // e sad ide if... if(imageHeight < imageWidth ){ //console.log("height je manji od width - LANDSCAPE"); screenImage.addClass("landscape"); } else if(imageHeight === imageWidth) { //console.log("height je jednak width - SQUARE"); } else { //console.log("height je VEĆI od width - PORTRAIT"); screenImage.addClass("portrait"); } }).each(function() { if(this.complete) $(this).load(); }); });