forked from DonLoron/media_type_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.php
37 lines (28 loc) · 1.28 KB
/
boot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
//ajax request must be done late
rex_extension::register("PACKAGES_INCLUDED", function(){
if(rex::isBackend() && rex_request::isXmlHttpRequest() && rex_request::get("action") != "") rex_media_type_set::handleAJAX(rex_request::get("action"));
});
if(!rex::isBackend()) {
rex_extension::register("OUTPUT_FILTER", function($p){
$page = $p->getSubject();
$addonConfig = $this->getConfig('addonConfiguration');
//if auto lazy load active, add js to head end
if($addonConfig['autoloadLazyload'] == 1) {
$js = '<script type="text/javascript" src="' . rex_url::assets('addons/media_type_manager/vendor/js/lazysizes.min.js') . '"></script>';
$page = str_replace('</body>', $js . '</body>', $page);
}
if($addonConfig['autoloadPicturefill'] == 1) {
$js = '';
if(rex_addon::get('useragent')->isAvailable()) {
if (useragent::isBrowserInternetExplorer()) {
$js = '<script src="' . rex_url::assets('addons/media_type_manager/vendor/js/picturefill.min.js') . '"></script>';
}
} else {
$js = '<script src="' . rex_url::assets('addons/media_type_manager/vendor/js/picturefill.min.js') . '"></script>';
}
if($js != '') $page = str_replace('</body>', $js . '</body>', $page);
}
return $page;
});
}