Skip to content

Images Retain Original Extensions but Are Delivered as WebP #22

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

Open
letherman255 opened this issue Nov 20, 2024 · 1 comment
Open

Images Retain Original Extensions but Are Delivered as WebP #22

letherman255 opened this issue Nov 20, 2024 · 1 comment

Comments

@letherman255
Copy link

Hi @Mecanik,

Thanks a lot for this great worker—it has saved us a ton of time and improved our site performance significantly!

We’ve implemented the worker as described, and it’s functioning well. Images are being dynamically converted to WebP and served correctly, which we verified using tools like an online WebP analyzer. However, there’s a small issue we’ve encountered:

When a user right-clicks on an image and selects "Open Image in New Tab" or "Save Image As," the file retains its original extension (e.g., .jpg or .png) even though the content is actually WebP.

This behavior can be confusing for end users and poses challenges when:

  1. Users try to view these files with software that doesn’t support WebP(e.g., older photo viewers).
  2. Some tools incorrectly treat the files based on their extensions rather than their MIME types.

We noticed that other websites using WebP prevent users from downloading images with their original extensions altogether. Instead, the downloaded files explicitly use .webp.

Would it be possible to adjust the worker to rewrite image URLs with their actual extensions (e.g., .webp) or to add a Content-Disposition header to ensure correct saving behavior?

If there’s already a solution or workaround for this, we’d love to hear about it! Thanks again for your incredible work on this tool.

@Mecanik
Copy link
Owner

Mecanik commented Nov 20, 2024

Hi, glad it helped you. That's because cloudflare alters the content type of the image rather than extension, it does not touch the extension.

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

No branches or pull requests

2 participants