Skip to content Skip to sidebar Skip to footer

Jquery: Dynamic Image Resize

I'm trying to do a responsive theme for wordpress. For preparation, I'm creating my resize script using JQuery to dynamically adjust it when needed. <

Solution 1:

Try setting an integer on now_height,now_width variables

var now_height = parseInt(height * percent);
var now_width = parseInt(width * percent);

also try calling your function on $(window).load() event

$(window).load(function(){
    resize.bindimage('img');
});

also checkout the scope of variable width,height you are using it inside the resize function but it isn't readable there...change your code to something like this

<scriptlanguage="javascript"type="text/javascript">var width = 0;
var height = 0;
var resize = {
bindimage: function (containerid) {
        width = $(containerid).width();
        height = $(containerid).height();

Post a Comment for "Jquery: Dynamic Image Resize"