Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
Right click "save as" selects jpg image instead of webp, but webp is displayed

I'm using .htaccess to serve webp images to browsers that support it.

RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png|gif)$ $1.webp [T=image/webp,E=REQUEST_image]
Header append Vary Accept env=REQUEST_image
AddType image/webp .webp

Source: WebP images with htaccess

Basically what it does is return a .webp image instead of the requested jpg/png/gif, from the same location, if it exists and is supported.

This works fine in Chrome, Firefox, IE11, Edge... Haven't tested Safari.

My issue is however that when I right click on the website, "save as", it automatically selects a .jpg version. If a .jpg version doesn't exist it tries to save the whole html. Intended behaviour would be for it to save the displayed .webp version, if it is used. Weirdly enough it does try to save the .webp in Firefox when doing the same, but when I try the same thing using Page info in Firefox (ctrl+i on Windows), it selects the .jpg.

How is this even possible? Is there something missing/wrong with this?

I checked that the displayed image is an actual webp, and it is. Both content-type and file size matches that of the webp.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

my working solution is:


Check if browser supports WebP images

RewriteCond %{HTTP_ACCEPT} image/webp

Check if WebP replacement image exists

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} -f

Serve WebP image instead

RewriteRule (.+)\.(jpe?g|png|gif)$ $1.webp [T=image/webp,E=REQUEST_image]

so try to change RewriteCond %{DOCUMENT_ROOT}/$1.webp -f to

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} -f

Tested on Safari and Firefox.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!