mpratt / Embera

A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
MIT License
335 stars 59 forks source link

youtube rel=0 ? #62

Closed interfixnet closed 4 years ago

interfixnet commented 4 years ago

Am I correct in thinking that there is no support in Embera for the rel=0 youtube parameter that limits related videos to the channel that produced it?

mpratt commented 4 years ago

Hi!

You are right! the oembed implementation on Youtube does not support this. However in version +2.0 of embera you might get away by using filters.

$embera = new Embera();
$embera->addFilter(function ($response) {
    if (!empty($response['html']) && $response['embera_provider_name'] == 'Youtube') {
        $response['html'] = str_ireplace('feature=oembed', 'feature=oembed&rel=0', $response['html']);
    }

    return $response;
});
// do your thing

However, this is a new version of Embera, so make sure to read the documentation and migrate your code in order to avoid problems.