Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Ability to set the XHR Header #947

Open
LorenDorez opened this issue Jan 14, 2021 · 3 comments
Open

Feature Request: Ability to set the XHR Header #947

LorenDorez opened this issue Jan 14, 2021 · 3 comments

Comments

@LorenDorez
Copy link

Hi,

We use Pannellum behind a CloudFlare setup. We are enabling a feature in CF called Polish that help to optimize images passing through it. One of the feature is it will convert/compress JPG to Webp but the Accept header must explicitly contain 'image/webp' and currently pannellum sends 'images/*'.

It would be nice if this could be controlled via a setting/option. For now im going to modify our local version of the js file

@mpetroff
Copy link
Owner

I'm not convinced this is something that should be exposed.

I would recommend against always setting the Accept header to explicitly contain image/webp, since it will break support for browsers that do not support WebP. It should only be added using feature detection, which, unfortunately, is not straightforward for image formats (browser vendors should really add a JavaScript API for this, IMHO).

In general, I would also recommend against using automatic lossy image recompression of web-quality JPEG images when image quality is important (such as for panoramas). Yes, the file size may be reduced, but the image quality is frequently reduced as well. For high-quality images, WebP does not necessarily do better than JPEG at equivalent bitrates, anyway.

@LorenDorez
Copy link
Author

LorenDorez commented Jan 17, 2021

Hello,

Thanks for the reply.

Unfortunately I dont have much of a choice here as that the direction the my company is taking with the use of the CloudFlares Polish tool. It will only cache at the CF edge in webp. So our company is trying to decrease bandwidth etc from Origin server to CF.

At the end of the day I just thought it would save me carrying a custom build of the plugin if it was exposed to allow me to overwrite the headers when needed. I understand I need to wire-up feature support detection for webp and probably going to go with Google and Mondernizer recommended detection logic there.

I do understand being hesitant about exposing this, so ill just do all my logic in a separate function/file and then just update the plugin source to call my method. This way it will be easier to update the plugins src and modify each time.

Again thanks for the reply and love this plugin by the way.

@mpetroff
Copy link
Owner

I just opened an issue on the HTML standard repository about adding a method for checking if a browser supports a specific image format. If such a method is eventually adopted by browsers, I'll revisit this feature request, so I'm going to leave it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants