|
|
|
|
|
by mzajc
304 days ago
|
|
If you can afford to add a little extra logic to your web server, you can solve this without JavaScript shenanigans (plus it doesn't leak your visitors' IPs to Google. On Nginx, for example: location ~ /vi/(.*)/thumbnail($|\..*) {
error_page 404 = @hqdefault;
proxy_intercept_errors on;
proxy_pass https://img.youtube.com/vi/$1/maxresdefault$2;
}
location @hqdefault {
proxy_pass https://img.youtube.com/vi/$1/hqdefault$2;
}
Then simply use /vi/<id>/thumbnail.webp as the image source or adapt the location regex as needed. This can be chained with yet more fallback URLs. |
|