[OpenLayers-Trac] [OpenLayers] #2893: Problems calculating popup size when it contains an image with 302 redirect

OpenLayers trac-20090302 at openlayers.org
Tue Oct 19 03:58:55 EDT 2010

#2893: Problems calculating popup size when it contains an image with 302 redirect
 Reporter:  gregers                            |       Owner:  euzuro      
     Type:  bug                                |      Status:  new         
 Priority:  minor                              |   Milestone:  2.11 Release
Component:  Popup                              |     Version:  SVN         
 Keywords:  popup image getrendereddimensions  |       State:              
 The popup does not get correct size when it contains an image that gets a
 302 redirect.

 This causes some weird behaviour:
 - First of all, the onImgLoad function won't be bound if the image has an
 alt text. Since the img.width then is the width of the alt text. Somehow
 this is not the case when there is no 302 redirect.
 - When Util.getRenderedDimensions inserts the popup-html to calculate the
 size, the original src is used. Since it's a temporary redriect the
 browser tries to load the image again instead of accessing the browser

 The alt text problem is easy to get around by checking img.complete ===

 But the other is worse. The only suggestion I have is to add the width and
 height of the image in the onImgLoad handler. That will make sure the
 image has the correct size for Util.getRenderedDimensions.
     if(this.img && this.img.width) {
         this.img.setAttribute("width", this.img.width);
     if(this.img && this.img.height) {
         this.img.setAttribute("height", this.img.height);

 302-redirects on images is probably quite rare, but I guess I'm not the
 only one that might get into this problem.

Ticket URL: <http://trac.openlayers.org/ticket/2893>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer

More information about the Trac mailing list