Reputation: 397
The png
and jpg
images of my Wordpress site are programatically converted into webp
formats thanks to an extension (I've tried different, including WebP Converter for Media and WebP Express).
There are pages that display an image. I would like to add a button that enable users to download the image. I'm currently using the following code :
<a href="path/to/my/img.png" download="img">
<button type="button"> Download </button>
</a>
Nevertheless, upon hit, the image to be download corresponds to its webp
version - not the png
as encoded in the image path.
I would like to know :
png
image upon button click, either with a client side information (included in the image path, or in the ?) or with a server side condition (if page==X and request==Y, return png)?png
to webp
, either by excluding some pages in a given extension, or by adding some php
functions directly in the code ?Otherwise, what other strategies have I missed to have webp
images rendered but the ability to easily save as png
?
Note: Chrome works as expected : png instead of webp image upon download, and, webp image upon save as
on image directly. Firefox though download images as webp wether it is on the image or through the download button.
Upvotes: 0
Views: 1323
Reputation: 397
I haven't find a definitive general answer, but apparently, the WebP Express plugin skips URLs that contain a query string.
Therefore, if you ?original
to the image URL in the link, you would "force" the serve not to encode your original png image into a webp format.
This just writes :
<a href="path/to/my/img.png?original" download="img">
<button type="button"> Download </button>
</a>
Note : I don't know whether this works with other plugins.
Upvotes: 2