function oembed_get_data in oEmbed 8
Same name and namespace in other branches
- 7 oembed.module \oembed_get_data()
- 7.0 oembed.module \oembed_get_data()
Fetch data for an embeddable URL.
Parameters
string $url: An external URL for the content to embed.
array $parameters: An associative array of request parameters, with the following keys:
- 'maxwidth' The maximum width of the embed, in pixels.
- 'maxheight' The maximum height of the embed, in pixels.
Other keys may be supported by some providers (twitter, youtube, wordpress).
Return value
bool|array False or an array representing the embeddable data of the URL.
7 calls to oembed_get_data()
- MediaInternetOEmbedHandler::getOEmbed in ./
MediaInternetOEmbedHandler.inc - Returns an array representation of the oEmbed data, or NULL on failure.
- oEmbed::preRenderFetch in src/
Element/ oEmbed.php - OembedTestCase::testOembedProviderUrls in ./
oembed.test - Tests that actual response type matches the expected response type.
- oembed_field_attach_validate in ./
oembed.filter.inc - Implements hook_field_attach_validate().
- oembed_file_load in ./
oembed.file.inc - Implements hook_file_load().
File
- ./
oembed.module, line 107 - Core functionality for oEmbed
Code
function oembed_get_data($url, $parameters = array()) {
$parameters = array_filter($parameters);
/** @var \Bangpound\oEmbed\Consumer $consumer */
$consumer = \Drupal::service('oembed.consumer');
try {
$data = $consumer
->get($url, $parameters);
return $data;
} catch (\RuntimeException $e) {
return false;
}
}