Created
February 14, 2024 19:41
-
-
Save AngelKrak/38ac2fee64888602d966e15288fe80b0 to your computer and use it in GitHub Desktop.
getImage by Weserv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const imageUrl = (url, opts) => | |
`https://wsrv.nl/?${new URLSearchParams({ | |
/* The image URL to optimize */ | |
url, | |
/* In case something goes wrong, just show the image */ | |
default: url, | |
/* | |
Compress it as much as possible (PNG). | |
See: https://images.weserv.nl/docs/format.html#compression-level | |
*/ | |
l: 9, | |
/* | |
Reduce PNG file size. | |
See: https://images.weserv.nl/docs/format.html#adaptive-filter | |
*/ | |
af: '', | |
/* | |
Enable image optimization for GIF and JPEG. | |
See: https://images.weserv.nl/docs/format.html#interlace-progressive | |
*/ | |
il: '', | |
/* | |
Enable image optimization for WebP and GIF. | |
See: https://images.weserv.nl/docs/format.html#number-of-pages | |
*/ | |
n: -1, | |
/* | |
Pass any other option. | |
See https://images.weserv.nl/docs/quick-reference.html | |
It's recommended to pass `w` for cutting down the image size. | |
*/ | |
...opts | |
}).toString()}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment