When assigning image/jpeg to the "file format:" pull-down for a wms layer and then displaying the layer the sites/all/modules/openlayers/OpenLayers-2.9.1/OpenLayers.js file changes the format from image/jpeg to image/png. I have temporarily fixed this by finding the 2 places where /OpenLayers.js changes image/jpeg to image/png by preventing this from happening. Somehow what is passed to /OpenLayers.js as far as the format is interpreted as needing to change from image/jpeg to image/png. When I use openlayers outside of Drupal and the openlayers module and pass a format of image/jpeg to openlayers it does not change it to image/png.

Below is the area that I had to modify within /OpenLayers.js:
if(this.params.FORMAT=="image/jpeg"){this.params.FORMAT=OpenLayers.Util.alphaHack()?"image/gif":"image/png";

Comments

tmcw’s picture

Category: bug » support

Is your WMS layer set as transparent? If it is, then OpenLayers will change the format to png, because jpegs can't be transparent. The relevant chunk of code is around the part you changed:

        if (!this.noMagic && this.params.TRANSPARENT && 
            this.params.TRANSPARENT.toString().toLowerCase() == "true") {
            
            // unless explicitly set in options, make layer an overlay
            if ( (options == null) || (!options.isBaseLayer) ) {
                this.isBaseLayer = false;
            } 
            
            // jpegs can never be transparent, so intelligently switch the 
            //  format, depending on teh browser's capabilities
            if (this.params.FORMAT == "image/jpeg") {
                this.params.FORMAT = OpenLayers.Util.alphaHack() ? "image/gif"
                                                                 : "image/png";
            }
        }
mitchelljj’s picture

No I have not set the image/jpeg layer to transparent. Which leads me to think based on the previous comment that even though I did not check the transparent checkbox that the openlayers module is passing transparent as true to OpenLayers.js.

tmcw’s picture

You're right, it's just hardcoded in there. I'll pull it out in a second.

tmcw’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.