Get the thumbnail of youtube and vimeo videos from the url. The returned information is ID and URL of the thumbnail
Install the latest version with
$ composer require fernandovaller/thumbnail
<?php
use FVCode\Thumbnail\Thumbnail;
require __DIR__ . '/vendor/autoload.php';
$th = new Thumbnail();
$url = 'youtube|vimeo URL video';
// The returned information is ID and URL of the thumbnail
$data = $th->get($url);
Vimeo videos can have origin restriction, in which case add the setting to simulate the origin in the request.
<?php
use FVCode\Thumbnail\Thumbnail;
require __DIR__ . '/vendor/autoload.php';
$config = [
'origin' => 'https://www.google.com'
];
$th = new Thumbnail($config);
$url = 'youtube|vimeo URL video';
// The returned information is ID and URL of the thumbnail
$data = $th->get($url);
<?php
use FVCode\Thumbnail\Thumbnail;
require __DIR__ . '/vendor/autoload.php';
$th = new Thumbnail();
$url = 'youtube|vimeo URL video';
// The returned information is array [title, thumbnail_url, video_id, ...]
$data = $th->getNoembed($url);