fernandovaller/thumbnail

Get the thumbnail of youtube and vimeo videos from the url. The returned information is ID and URL of the thumbnail

v1.0.5 2021-12-28 14:10 UTC

This package is auto-updated.

Last update: 2024-04-28 19:01:34 UTC


README

Get the thumbnail of youtube and vimeo videos from the url. The returned information is ID and URL of the thumbnail

Installation

Install the latest version with

$ composer require fernandovaller/thumbnail

Basic Usage

<?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);

Config

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);

Noembed

<?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);