diff --git a/autoload.php b/autoload.php index d04b955..c21c8e3 100644 --- a/autoload.php +++ b/autoload.php @@ -10,6 +10,7 @@ BearFramework\Addons::register('bearcms/embed-element-addon', __DIR__, [ 'require' => [ 'bearcms/bearframework-addon', - 'bearframework/localization-addon' + 'bearframework/localization-addon', + 'ivopetkov/client-shortcuts-bearframework-addon' ] ]); diff --git a/components/embedElement.php b/components/embedElement.php index 15e0dd0..4ee2fb4 100644 --- a/components/embedElement.php +++ b/components/embedElement.php @@ -135,8 +135,7 @@ } ?>
- - + = $content ?> \ No newline at end of file diff --git a/composer.json b/composer.json index 1ff905c..f43493d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "php": ">=7.1", "bearcms/bearframework-addon": "1.*", "bearframework/localization-addon": "0.2.*", - "ivopetkov/html5-dom-document-php": "2.*" + "ivopetkov/html5-dom-document-php": "2.*", + "ivopetkov/client-shortcuts-bearframework-addon": "0.1.*" }, "autoload": { "files": ["autoload.php"] diff --git a/index.php b/index.php index fcd32d0..9df1154 100644 --- a/index.php +++ b/index.php @@ -55,5 +55,20 @@ ] ]); }; + + $app->clientShortcuts + ->add('-bearcms-embed-element-responsively-lazy', function(IvoPetkov\BearFrameworkAddons\ClientShortcut $shortcut) use ($context) { + $shortcut->requirements[] = [ + 'type' => 'file', + 'url' => $context->assets->getURL('assets/responsivelyLazy.min.js', ['cacheMaxAge' => 999999999, 'version' => 2]), + 'async' => true, + 'mimeType' => 'text/javascript' + ]; + $shortcut->requirements[] = [ + 'type' => 'text', + 'value' => '.responsively-lazy:not(img){position:relative;height:0;}.responsively-lazy:not(img)>img{position:absolute;top:0;left:0;width:100%;height:100%}img.responsively-lazy{width:100%;}', + 'mimeType' => 'text/css' + ]; + }); }; });