On this page
Modifying and Extending URL Embed
Last updated on
23 February 2024
This documentation needs work. See "Help improve this page" in the sidebar.
This page lists APIs, hooks, and other methods for customizing URL Embed.
Modify the response provided by oEmbed
Some oEmbed implementations provide parameters to modify what the provider returns as a response. For example X allows a "limit" parameter to limit the number of Tweets.
For scenarios like this, use hook_url_embed_options_alter()
Example usage
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]]]);
}
}Help improve this page
Page status: Needs work
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion