getting image size in google chrome is undefined

blindkilla

New Member
I have several image tags and div in my html as below. My requirment is to calculate the height * width of each image and do the following if the height * width is <5000. 1) Remove the correspponding div 2) remove the class 'captify' of correcsponding imageFor this I have tried the below script for handling google chrome since I have managed to work for IE and firefox using some other method.\[code\]$('img[class = "captify"]').each(function(){var $that = $(this),picRealWidth = 0,picRealHeight = 0,imgSize = 0,dvHiResCaption = null,src = http://stackoverflow.com/questions/12799666/$that.attr('src' ),rel = $that.attr( 'rel' );// creating a clone in memory$('<img/>').attr('src', src).load(function(){picRealWidth = parseInt( this.width );picRealHeight = parseInt( this.height );}, function(){// called once the load is completeimgSize = picRealWidth * picRealHeight;if( imgSize < 5000 ){dvHiResCaption = '#' + rel;$(dvHiResCaption).remove();$that.removeClass( 'captify' );}});});\[/code\]Can any one help me on this please. Many thanks in advance
 
Back
Top