code: function() { 
  
          // As the images load, this function will call updateSize() to 
          // resize the popup to fit the content div (which presumably is now
          // bigger than when the image was not loaded).
          // 
          // If the 'panMapIfOutOfView' property is set, we will pan the newly
          // resized popup back into view.
          // 
          // Note that this function, when called, will have 'popup' and 
          // 'img' properties in the context.
          //
          var onImgLoad = function() {
              if (this.popup.id === null) { // this.popup has been destroyed!
                  return;
              }
              this.popup.updateSize();
       
              if ( this.popup.visible() && this.popup.panMapIfOutOfView ) {
                  this.popup.panIntoView();
              }
  
              OpenLayers.Event.stopObserving(
                  this.img, "load", this.img._onImgLoad
              );
      
          };
  
          //cycle through the images and if their size is 0x0, that means that 
          // they haven't been loaded yet, so we attach the listener, which 
          // will fire when the images finish loading and will resize the 
          // popup accordingly to its new size.
          var images = this.contentDiv.getElementsByTagName("img");
          for (var i = 0, len = images.length; i < len; i++) {
              var img = images[i];
              if (img.width == 0 || img.height == 0) {
  
                  var context = {
                      'popup': this,
                      'img': img
                  };
  
                  //expando this function to the image itself before registering
                  // it. This way we can easily and properly unregister it.
                  img._onImgLoad = OpenLayers.Function.bind(onImgLoad, context);
  
                  OpenLayers.Event.observe(img, 'load', img._onImgLoad);
              }    
          } 
      }
docs: Method: registerImageListeners
  Called when an image contained by the popup loaded. this function
  updates the popup size, then unregisters the image load listener.