Posted By

quantal on 01/14/12


Tagged

resize image jquery fixed


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

Balamir
burnandbass
spee66
lcrt
BrockSamsom
lookingforsome
catrinho
imoddesign
Joysr
nhoxzunbmt


İmage resize


 / Published in: jQuery
 

jquery fixed image resize

  1. $(window).bind("load", function() {
  2. // IMAGE RESIZE
  3. $('#product_cat_list img').each(function() {
  4. var maxWidth = 120;
  5. var maxHeight = 120;
  6. var ratio = 0;
  7. var width = $(this).width();
  8. var height = $(this).height();
  9.  
  10. if(width > maxWidth){
  11. ratio = maxWidth / width;
  12. $(this).css("width", maxWidth);
  13. $(this).css("height", height * ratio);
  14. height = height * ratio;
  15. }
  16. var width = $(this).width();
  17. var height = $(this).height();
  18. if(height > maxHeight){
  19. ratio = maxHeight / height;
  20. $(this).css("height", maxHeight);
  21. $(this).css("width", width * ratio);
  22. width = width * ratio;
  23. }
  24. });
  25. //$("#contentpage img").show();
  26. // IMAGE RESIZE
  27. });

Report this snippet  

You need to login to post a comment.