Igor OA
Igor OA

Reputation: 397

Wordpress : Prevent from serving webp images on button-based download

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 :

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

Answers (1)

Igor OA
Igor OA

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

Related Questions