function _thunder_amp_set_oembed_attributes in Thunder 8.3
Set's width and height for oEmbed items.
2 calls to _thunder_amp_set_oembed_attributes()
- thunder_amp_preprocess_media__source_oembed__derivative_video__provider_vimeo in themes/
thunder_amp/ thunder_amp.theme - Implements hook_preprocess_HOOK().
- thunder_amp_preprocess_media__source_oembed__derivative_video__provider_youtube in themes/
thunder_amp/ thunder_amp.theme - Implements hook_preprocess_HOOK().
File
- themes/
thunder_amp/ thunder_amp.theme, line 49 - Preprocess html for thunder_amp theme.
Code
function _thunder_amp_set_oembed_attributes(&$variables, $url) {
/** @var \Drupal\media\OEmbed\UrlResolverInterface $url_resolver */
$url_resolver = \Drupal::service('media.oembed.url_resolver');
$resource_url = $url_resolver
->getResourceUrl($url);
/** @var \Drupal\media\OEmbed\ResourceFetcherInterface $resource_fetcher */
$resource_fetcher = \Drupal::service('media.oembed.resource_fetcher');
$resource = $resource_fetcher
->fetchResource($resource_url);
$variables['attributes']['width'] = $resource
->getWidth();
$variables['attributes']['height'] = $resource
->getHeight();
}