Skip to content Skip to sidebar Skip to footer

Resize Image With JQuery

The scenario: I’m building a website, which will not Host the images in its own server. Instead it will reference images from other servers. Example: The website is hosted at www

Solution 1:

you can easily do it by maintaining the aspect ratio.

define max width and max height.

by maintaining aspect ratio resize them.

  if ((h / w) < (maxH / maxW)) {
                $img.css('height', '');
                $mg.css('width', maxW);
            }
            else {
                $Img.css('height', maxH);
                $Img.css('width', '');

Post a Comment for "Resize Image With JQuery"