Remix.run Logo
mzajc 6 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.
onestay42 6 days ago | parent | next [-]

Please, please close that parenthese. Please, I beg of you. I can do it for you if you'd like.) There. Sorry.

mzajc 6 days ago | parent [-]

The edit button is gone, sorry :)

6 days ago | parent | prev [-]
[deleted]