

There's no need to use functions when setting the width/height. Use our tire size calculator to calculate the diameter, width, sidewall. And undefined * container.width() is NaN - Not a Number. Stranger still, when you actually call setImageDims in the resize event handler, you don't provide that value at all, meaning it's undefined. And you basically "rename" it to container inside the function, so perhaps that'd be a better name to begin with? And $imgAspectRatio would imply that it's a jQuery object. selector is fine (if non-descriptive), but content_area is snake_case whereas you use camelCase (which is the JavaScript convention) everywhere else. There's little system in your variable-naming. Of course, you already have a resizeImage function which does the exact same thing - it's just hard coded to only use the body as its reference. A 16:9 ratio (pronounced 16 9, 16 to 9, or 16 by 9 and sometimes written as 16×9) is an aspect ratio, where for every 16 units of width, there are 9 corresponding units of height.Examples of 16:9 ratios are 16 inches wide by 9 inches high, 32 widgets wide by 18 widgets high, and 1920 pixels wide by 1080 pixels high.

For another, I'd just find resizeImage or maybe resizeToMatch to be more straightforward. Enter the values for the original width (W 1) & original height (H 1) on the left.

For one, I rarely see the need to abbreviate words.
#Width aspect ratio calculator code#
There's a lot of code here, so I'll just start with a single function: setImageDims I have also created a rudimentary fiddle to illustrate the imageCalc(), setImageDims(), and imageResize() functionality here. JQuery('.menu-main-container').css('display', 'block') Although aspect ratios are widely used in applications such as tire sizing, paper sizing, and standard photographic print sizes, some of the most frequent uses of aspect ratios. In the case of a rectangle, the aspect ratio is that of its width to its height. SetImageDims('.com-background > img', '#main-content') The aspect ratio is the ratio of a geometric shape's sizes in different dimensions. setImageDims('.com-background > img', '#main-content', ratio1) var ratio1 = imageCalc('.com-background > img') JQuery('.mobile-contain > a').bind(event, function(), 7000) Enter the measurement that you know and the other two will be calculated. Var ua = erAgent var event = (ua.match(/iPad/i)) ? 'touchstart' : 'click' Note: all these functions work (I do have an error imageResize('.com-background > img', ratio1) ratio1 is not defined within the window.resize function. The below scriptfile includes the issue above, and some functionality for mobile, and an overlay. First, an image gallery I have setup and now, Iframes. Now, I have got these functions working, however I feel like they could be more efficient/clean. I have created a set of functions to calculate the aspect ratio of an image, set a height/width on document.ready and on window.resize resize the image.
