public function BlazyOEmbed::build in Blazy 8.2
Builds media-related settings based on the given media input url.
Parameters
array $settings: The settings array being modified.
Overrides BlazyOEmbedInterface::build
1 call to BlazyOEmbed::build()
- BlazyOEmbed::getMediaItem in src/
BlazyOEmbed.php - Gets the Media item thumbnail.
File
- src/
BlazyOEmbed.php, line 146
Class
- BlazyOEmbed
- Provides OEmbed integration.
Namespace
Drupal\blazyCode
public function build(array &$settings = []) {
if (empty($settings['_input_url'])) {
$this
->checkInputUrl($settings);
}
// @todo revisit if any issue with other resource types.
$url = Url::fromRoute('media.oembed_iframe', [], [
'query' => [
'url' => $settings['input_url'],
'max_width' => 0,
'max_height' => 0,
'hash' => $this->iframeUrlHelper
->getHash($settings['input_url'], 0, 0),
'blazy' => 1,
'autoplay' => empty($settings['media_switch']) ? 0 : 1,
],
]);
if (!empty($settings['iframe_domain'])) {
$url
->setOption('base_url', $settings['iframe_domain']);
}
// The top level iframe url relative to the site, or iframe_domain.
$settings['embed_url'] = $url
->toString();
if (isset($settings['media_source'])) {
$settings['type'] = $settings['media_source'] == 'oembed:video' ? 'video' : $settings['media_source'];
$settings['type'] = $settings['media_source'] == 'video_embed_field' ? 'video' : $settings['type'];
}
}