如何youtube缩略图链接替换为站点链接

I have problem youtube video and thumbnails block in our country and I want to run youtube api for getting these data , but problem is thumbnails links show like these link

enter image description here

I want to its show through my site link with my server like

https://img.example.com/vi/T0Jqdjbed40/default.jpg

I try to replace url with string replace function but its not work please tell me how to run through my site link like some site show like playit , vube.pk , flix

As a purely theoretical thing, you can replace sections of a string using the str_replace function:

str_replace(
    "https://i.ytimg.com/vi/T0Jqdjbed40/default.jpg",
    "://i.ytimg.com", "://img.example.com");

This will keep the http:// or https:// protocol in place.


For your use case, again purely theoretically, you would want to download the resource yourself, and then provide it to the end user. To get the data using file_get_contents for example:

$data = file_get_contents('http://www.example.com/');

You culd then potentially embed the image data directly into the page itself - see this SO question: Can I embed a .png image into an html page?

You should probably check youtube's terms of service before attempting anything...