public static function Blazy::buildIframe in Blazy 8.2
Modifies variables for iframes, those only handled by theme_blazy().
Prepares a media player, and allows a tiny video preview without iframe. image : If iframe switch disabled, fallback to iframe, remove image. player: If no colorbox/photobox, it is an image to iframe switcher. data- : Gets consistent with colorbox to share JS manipulation.
Parameters
array $variables: The variables being modified.
Overrides BlazyInterface::buildIframe
2 calls to Blazy::buildIframe()
- Blazy::buildMedia in src/
Blazy.php - Modifies variables for image and iframe.
- BlazyUnitTest::testBuildIframe in tests/
src/ Unit/ BlazyUnitTest.php - Tests \Drupal\blazy\Blazy::buildIframe.
File
- src/
Blazy.php, line 219
Class
- Blazy
- Provides common blazy utility static methods.
Namespace
Drupal\blazyCode
public static function buildIframe(array &$variables) {
$settings =& $variables['settings'];
$settings['player'] = empty($settings['lightbox']) && $settings['media_switch'] == 'media';
if (empty($variables['url'])) {
$variables['image'] = empty($settings['media_switch']) ? [] : $variables['image'];
// Pass iframe attributes to template.
$variables['iframe'] = [
'#type' => 'html_tag',
'#tag' => 'iframe',
'#attributes' => self::iframeAttributes($settings),
];
// Iframe is removed on lazyloaded, puts data at non-removable storage.
$variables['attributes']['data-media'] = Json::encode([
'type' => $settings['type'],
]);
}
}