How can I add player parameters to a core oembed field for a youtube video?

drupal.stackexchange https://drupal.stackexchange.com/questions/299160

  •  01-03-2021
  •  | 
  •  

Question

For example, if I enter this url that contains the player parameters to remove controls and autoplay, oembed field on my media type does not allow it ("The given URL does not match any known oEmbed providers.".

https://youtu.be/9ot0rIlhbNE?autoplay=1&fs=0&controls=0&modestbranding=1

screenshot

If I paste just the base url, then it works.

Any thoughts?

Edit: Based on Yuseferi answer, I have isolated the Youtube section if the providers.json.

{
    "provider_name": "YouTube",
    "provider_url": "https:\/\/www.youtube.com\/",
    "endpoints": [
        {
            "schemes": [
                "https:\/\/*.youtube.com\/watch*",
                "https:\/\/*.youtube.com\/v\/*",
                "https:\/\/youtu.be\/*"
            ],
            "url": "https:\/\/www.youtube.com\/oembed",
            "discovery": true
        }
    ]
}
Était-ce utile?

La solution

I had the same problem before with a local provider. So I share the solution I used and hope it works for you too.

The Drupal core, fetch providers form https://oembed.com/providers.json automatically. So you need to change the provider to what you want.

Oembed Providers module helps to add custom providers too.

  • Add custom oEmbed providers via an admin user interface (providers are stored in configuration)
  • Global enable/disable of providers
  • Modify the provider list URL (which is > defaulted to https://oembed.com/providers.json)
  • Disable the fetching of the provider list (useful in an instance where only custom providers are used)
  • Provides hook_oembed_providers_alter() to alter provider definitions

So, all you need is to add a new provider for your custom provider "youtu.be" with your parameters too.

try it and let me know if you need more details.;)

Screenshots that shows it's working without any validation error:

enter image description here

enter image description here

what I did, was just add "oembed_providers" module and enabled it

Licencié sous: CC-BY-SA avec attribution
Non affilié à drupal.stackexchange
scroll top