(function($){
	
	$.fn.scalecropImg = function() {
		return this.each(function() {
			
			//css width and height
			var cw = $(this).css('width');
			var ch = $(this).css('height');
			
			cw = cw.split('px');
			ch = ch.split('px');
			cw = cw[0];
			ch = ch[0];
			
			
			//properties width and height
			var pw = $(this).width();
			var ph = $(this).height();
			
			var w;
			var h;
			
			if(cw != 'auto' && ch != '0'){
				w = cw;
			}else{
				w = pw;
			}
			
			if(ch != 'auto' && ch != '0'){
				h = ch;
			}else{
				h = ph;
			}
			
			var b = $(this).attr('src');
					
			b = b.split('.');
			
			var type = b[1];
			b = b[0];
			
			var url = b+"_"+w+"_"+h+"."+type;
			
			$(this).attr('src',url)
		});
	};
})( jQuery );

