Continuing from a previous discussion on CSS Display an Image Resized and Cropped, I am in need of further assistance to enhance the existing solution provided by a fellow user...
Question: How can we dynamically resize (scale) the image based on its original size at runtime? Instead of hard-coding specific dimensions like "width: 320px; height: 221px;" in the style, I am looking for a way to relate the resizing to the actual image dimensions.
Below are some jsfiddles for reference:
http://jsfiddle.net/VdX68/ - This is based on the initial answer given in the thread. It works well if you know the image's dimensions beforehand.
http://jsfiddle.net/VdX68/4/ - In this version, the image dimensions do not need to be known, but it only works for a 100% scale. Here, I removed the width and height attributes from the .scalePan class.
http://jsfiddle.net/VdX68/2/ - This example uses percentages for width and height. The image scales according to the size of the containing div, not its original dimensions.
I am seeking a method to scale the image based on a percentage of its original dimensions, rather than a percentage of the container it resides in.
Any assistance on this matter would be greatly appreciated.