Scale Images


An Intelligent Image Scaling jQuery Plugin

This is a jQuery plugin to scale images to optimize their size relative to the viewport, while retaining their aspect ratio. This is not possible with CSS alone, as each image needs to be evaluated individually. This is compared to the viewport size, and the image is scaled to be as large as it can be while still being entirely visible within the viewport.

While this is a relatively simple script, it does solve a ubiquitous problem amongst photographers. On a typical photo blog the images are sized to either fit vertically or horizontally, in either case creating images that are either too small or too large.

Because this uses the width and height attributes, it is not currently compatible with srcset.  However I do know how to get that done, and plan on doing so sometime in the future.