Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot exclude featured image #184

Open
mosaif opened this issue Nov 8, 2020 · 2 comments
Open

Cannot exclude featured image #184

mosaif opened this issue Nov 8, 2020 · 2 comments

Comments

@mosaif
Copy link

mosaif commented Nov 8, 2020

Hi there,

The script is really good, but I've been trying to exclude the featured image class= "single-featured" from the lazy load but not success. Is there away to do it?

@dinbror
Copy link
Owner

dinbror commented Nov 9, 2020

Hi @mosaif

How do you initialize blazy? Are you using the default setup where you need to add "b-lazy" as classname?

@mosaif
Copy link
Author

mosaif commented Nov 9, 2020

Hi @dinbror,

this is the initialization code. I am a total noob and I really appreciate your help.

`/**
* Initialize lazy loading
*/
initLazyLoad: function () {

        var options = {
            selector: '.img-holder,.img-cont,.bs-lazy,img[data-src],iframe[data-src]',

            itemLoaded: function (el, url) {

                if (el.tagName.toLowerCase() === 'iframe' && $.fn.fitVids) {
                    $(el.parentNode).fitVids();
                }
            }
        };

        if (this.betterLazyLoad.isActive()) {

            this.betterLazyLoad.init(options);

        } else if ('function' === typeof Blazy) {

            this.BLazyLoad(options);
        }

        this.likeBoxLazyLoad();
    },


    BLazyLoad: function (options) {

        // Images
        if (typeof Blazy !== "function") {
            return;
        }

        Publisher_Theme.bsLazy = new Blazy({
            selector: options.selector,
            loadInvisible: function (ele, isVisible) {

                if (!isVisible) {
                    while (ele = ele.parentElement) {
                        if (ele.className.match(/\bmega-menu\b/i)) {
                            return false;
                        }
                    }
                }

                return true;
            },
            successClass: ' ',
            success: function (el) {

                el.className = el.className + ' b-load-ready';
                setTimeout(function () {
                    el.className = el.className.replace('b-load-ready', '') + ' b-loaded';
                }, 100);
            },

            itemLoaded: function () {
                if ($.fn.fitVids) {

                    $(this.parentNode).fitVids();
                }
            }
        });
    },`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants