Back to PhocacartRenderMedia class

Method returnLazyLoad

public
returnLazyLoad
()

Method returnLazyLoad - Source code

public function returnLazyLoad()
{
    $s = array();
    $s[] = '<script>';
    $s[] = ' window.lazyLoadOptions = {	';
    $s[] = '   elements_selector: ".ph-lazyload",';
    $s[] = '   load_delay: 0,';
    $s[] = ' };';
    $s[] = ' window.addEventListener(\'LazyLoad::Initialized\', function (event) {';
    $s[] = '   window.phLazyLoadInstance = event.detail.instance;';
    $s[] = ' }, false);';
    $s[] = '</script>';
    $s[] = '<script async src="' . Uri::root(true) . '/media/com_phocacart/js/lazyload/lazyload.min.js"></script>';
    if ($this->p['lazy_load_category_items'] == 1 && ($this->view == 'category' || $this->view == 'items') && $this->load) {
        return implode("\n", $s);
    } else {
        if ($this->p['lazy_load_categories'] == 1 && $this->view == 'categories') {
            return implode("\n", $s);
        }
    }
    return '';
}