| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/JSEngine/libs/ |
Upload File : |
/* --------------------------------------------------------------
image_resizer.js 2016-02-23
Gambio GmbH
http://www.gambio.de
Copyright (c) 2016 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
jse.libs.image_resizer = jse.libs.image_resizer || {};
/**
* ## Image Resizer Library
*
* Resizes images with respective aspect ratio.
*
* @module JSE/Libs/image_resizer
* @exports jse.libs.image_resizer
*/
(function (exports) {
'use strict';
/**
* Resize an image element with the provided width and height values.
*
* @param {string} element Selector string for the image element to be resized.
* @param {object} options (optional) This object must contain the "width" and "height" properties.
*/
exports.resize = function (element, options) {
var $that = $(element);
var settings = {
width: 150,
height: 150
};
options = $.extend(settings, options);
var maxWidth = options.width;
var maxHeight = options.height;
var ratio = 0;
var width = $that.width();
var height = $that.height();
if (width > maxWidth) {
ratio = maxWidth / width;
$that.css('width', maxWidth);
$that.css('height', height * ratio);
}
if (height > maxHeight) {
ratio = maxHeight / height;
$that.css('height', maxHeight);
$that.css('width', width * ratio);
}
};
})(jse.libs.image_resizer);