Imagefit – Image scaling jQuery plugin

A jQuery plugin which scales images to fit their parent container.

It is reliant on support for the CSS property max-width to prevent images from being enlarged beyond their native resolution. For optimal image quality and minimised page weight nothing beats exporting your images to exactly the size they will display on the web page. Unfortunately image dimensions are often beyond our control. Perhaps JavaScript has the potential unlock those pixels and bring those unruly images into line with our flexible layouts.

Demo

JavaScript to proportionally scale images to fit.

Browser support

This JavaScript (version 0.2) has been written for use in a NetNewsWire style and as a result is optimised and tested to function with Safari 3.0.3 (and corresponding webkit in Mac OS X).

Also tested successfully in:

Known to fail in:

Unlikely to work in Internet Explorer

Download

jquery.imagefit.js