Garmaine Staff asked 1 year ago

I'm trying to make a custom JS for my WordPress to force Highest Quality Thumbnails for Youtube videos.

I found the Regex : https:\/\/i.ytimg.com\/vi\/(?:.+).jpg$

The example url should go from

https://i.ytimg.com/vi/***/hqdefault.jpg

To

https://i.ytimg.com/vi/***/maxresdefault.jpg

So the script needs to follow these steps:

1- Find all the Youtube Thumbnails (Regex Matching)
2- Replace hqdefault.jpg with maxresdefault.jpg and apply the change to the HTML

I tried for +24hours, but couldn't get the puzzle together… Thank you for helping out !