adeelejaz / jquery-image-resize Goto Github PK
View Code? Open in Web Editor NEWjQuery plugin to resize images - Please note you can also resize images using CSS. Check the link below.
License: MIT License
jQuery plugin to resize images - Please note you can also resize images using CSS. Check the link below.
License: MIT License
Hi. After implementing it and watching it working in Firefox and Chrome, what was my surprise when i loaded my page (http://www.universoweb.com/jordiescandell/fotografia.php?idimagen=130) in IE9 and realised that the plugin doesn´t work in this browser. Then checked your jsfiddle version and it doesn´t work either (http://jsfiddle.net/CpFDm/). Checking the code in firebug and ie9 developer tool it seems that, in IE, the image doesn´t print the new height and width values "on the fly". Hope you can find a solution because the plugin works fine in firefox and chrome. Thanks in advance.
Although this is minor, it's important to specify in the documentation that v2.1.1 does not size up, it only sizes image down.
Small images wont be sized up to the expected size.
Although this is generally the desired effect, it would be nice to have a simple option to 'force' a resize of the specified height/width
I like your plugin but i really needed the previous version that scales the image.
$('#thumbs img").resize(400);
This will configure the height that way the image isn't distorted. Can you add this option to the plugin?
Thanks,
Matt
I think you already noticed what from jQuery 1.9 they have the $.browser variable removed. ae will throw error and so not useable since that version.
Even using the latest version, the resize wasn't working for me in IE9. The fix is simple and means you can remove the "this.src = this.src" workaround:
;
(function($) {
$.fn.aeImageResize = function(params) {
var aspectRatio = 0;
// We cannot do much unless we have one of these
if (!params.height && !params.width) {
return this;
}
// Calculate aspect ratio now, if possible
if (params.height && params.width) {
aspectRatio = params.width / params.height;
}
// Attach handler to load
// Handler is executed just once per element
// Load event required for Webkit browsers
return this.one("load", function() {
// Remove all attributes and CSS rules
this.removeAttribute("height");
this.removeAttribute("width");
this.style.height = this.style.width = "";
var imgHeight = this.height, imgWidth = this.width, imgAspectRatio = imgWidth / imgHeight, bxHeight = params.height, bxWidth = params.width, bxAspectRatio = aspectRatio;
// Work the magic!
// If one parameter is missing, we just force calculate it
if (!bxAspectRatio) {
if (bxHeight) {
bxAspectRatio = imgAspectRatio + 1;
} else {
bxAspectRatio = imgAspectRatio - 1;
}
}
// Only resize the images that need resizing
if ((bxHeight && imgHeight > bxHeight) || (bxWidth && imgWidth > bxWidth)) {
if (imgAspectRatio > bxAspectRatio) {
bxHeight = ~~(imgHeight / imgWidth * bxWidth);
} else {
bxWidth = ~~(imgWidth / imgHeight * bxHeight);
}
$(this).height(bxHeight).width(bxWidth);
//this.height = bxHeight;
//this.width = bxWidth;
}
})
.each(function() {
// Trigger load event (for Gecko and MSIE)
if (this.complete) {
$(this).trigger("load");
}
// This fixes IE9 issue
//this.src = this.src;
});
};
})(jQuery);
We at VersionEye are working hard to keep up the quality of the bower's registry.
We just finished our initial analysis of the quality of the Bower.io registry:
7530 - registered packages, 224 of them doesnt exists anymore;
We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).
Sadly, your library adeelejaz/jquery-image-resize
is one of them.
Can you spare 15 minutes to help us to make Bower better?
Just add a new file bower.json
and change attributes.
{
"name": "adeelejaz/jquery-image-resize",
"version": "1.0.0",
"main": "path/to/main.css",
"description": "please add it",
"license": "Eclipse",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"<dependency_name>": "<semantic_version>",
"<dependency_name>": "<Local_folder>",
"<dependency_name>": "<package>"
},
"devDependencies": {
"<test-framework-name>": "<version>"
}
}
Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.
NB! Please validate your bower.json with jsonlint before commiting your updates.
Thank you!
Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!
It would be nice if the plugin would return an object with the new width and height values set to the image, so if you want to use the updated size of the image you don't have to query it again.
Only the first image with the same ID is resized. In IE8 and FF3, any number of images that share the same ID are resized.
WORKS
$(function() {
$( ".resizeme" ).aeImageResize({ height: 250, width: 250 });
});
DOES NOT WORK
$(function() {
$( "#resizeme" ).aeImageResize({ height: 250, width: 250 });
});
works in chrome 6beta. And in Firefox 3.6.8 but it's buggy - at the first pageload the images arent resized. Doesnt work at all in IE8 + IE8 Compatibility mode. Havent tested other browsers. Just thought id let u know. :)
Hi,
Hope you are still around.
Have an issue and get that error messgae:
"Uncaught TypeError: Object [object Object] has no method 'aeImageResize' "
I'm working on wordpress, paid attention to js files call order, just copy-pasted the function call from your doc : "$('.resizeme').aeImageResize", and added the resizeme class to my but still have this error. Any requirement I could have forget ?
I am dynamicly giving the src to my from an other dom elemnt if it can helps.
Thaks for any help
Sorry if this has been reported before.
I have noticed that when I use the plugin with some other Jquery plugins the image does not display at all or is not resized. If the browser is then refreshed the image will display correctly and is resized corretly.
I have two sites that I am using the plugin with and with both of them the image resizing is inconsistent.
At www.thescarletbow.com.au the About page displays an image of the author. On first page load the image does not display. Refresh the browser and the image is then displayed.
At www.stillframe.com.au/index.php (index.php must be in the URL) the About page displays an imge of the author. On first page load the image is not resized but the overflow is hidden as Ive placed the image inside a constrained div with overflow hidden. On refresh the image displays resized.
Any thoughts?
I want to have a form to allow a user to submit a photo, crop it and submit only the cropped image...
Is this possible with your code?
Thanks!
Patrick
in IE shows alert "Stack overflow at line: 0"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.