Skip to content

Instantly share code, notes, and snippets.

@adeelejaz
Last active January 12, 2016 23:28
Resize images using jQuery. Read more: https://adeelejaz.com/blog/type/jquery-image-resize-plugin/
$.fn.resize=function(a){var d=Math.ceil;if(a==null)a=200;var e=a,f=a;$(this).each(function(){var b=$(this).height(),c=$(this).width();if(b>c)f=d(c/b*a);else e=d(b/c*a);$(this).css({height:e,width:f})})};
$("img").resize(200);
$("#thumbs img").resize(150);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment