title: How to set the width of images loaded with ajax?
body: <p>I'm having a pictures website and have implemented infinite scrolling of pictures.
  The problem is that I don't know how to resize the images with jQuery after they are loaded.</p>
  
  <p>And I'm using drupal with jQuery version 1.5.</p>
  
  <p>This is my code so far that does not work:</p>
  
  <pre><code>jQuery(body).delegate("#region-content","onchange",function() {
  jQuery('#region-content img').each(function() {
      var desiredWidth = 520; // Max width for the image
      var ratio = 0;  // Used for aspect ratio
      var width = jQuery(this).width();    // Current image width
      var height = jQuery(this).height();  // Current image height
  
  
  
      if(width != desiredWidth){
          ratio = desiredWidth / width;   // get ratio for scaling image
          jQuery(this).css("width", desiredWidth); // Set new width
          jQuery(this).css("height", height * ratio);  // Scale height based on ratio
          height = height * ratio;    // Reset height to match scaled image
          width = width * ratio;    // Reset width to match scaled image
      }
  
  });
  });
  </code></pre>