Add ability to modify the embed options

Created on 19 May 2022, about 3 years ago
Updated 19 October 2023, over 1 year ago

Problem/Motivation

I want to limit the number of tweets that are rendered when adding a twitter timeline embed.

I have been researching and the oEmbed twitter implementation allow to provide a limit parameter to achieve this. However, there is not any way to pass this parameter to the embed https://github.com/oscarotero/Embed library (used by drupal/embed).

Proposed resolution

Implement a hook_url_embed_options_alter that is called just before the \Embed\Embed object is created and allow to modify the passed configuration.

Then, we would be able to accomplish this behavior by doing something like:

function my_module_url_embed_options_alter($url, &$config) {
  $parsedUrl = parse_url($url);

  if (($parsedUrl['host'] ?? '') == 'twitter.com') {
    $config = array_merge($config, ['oembed' => ['parameters' => ['limit' => 4]]]);
  }
}

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain unstatu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024