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

Unveilhooks tries to load page in data-link as css #750

Open
futtta opened this issue Feb 17, 2020 · 4 comments
Open

Unveilhooks tries to load page in data-link as css #750

futtta opened this issue Feb 17, 2020 · 4 comments

Comments

@futtta
Copy link

futtta commented Feb 17, 2020

Describe the bug
The WordPress core "gallery" block adds a data-link attribute to images with the link to the attachment page which lazysizes+unveilhooks tries to load assuming it is CSS.

To Reproduce
Example HTML as generated by WordPress Gallery block is at https://gist.github.com/futtta/ee0f5eeedbdba0d884ac1376def3d6f6

Steps to reproduce the behavior:

  1. In WordPress create a post/ page with the block editor, adding a gallery block.
  2. Install Autoptimize (which uses Lazysizes with Unveilhooks) and enable lazyload (settings -> autoptimize -> images -> lazyload checkbox)
  3. load the page/ post and observe the network activity to see how the attachment page is being loaded by unveilhooks

What is the expected behavior
Attachment page is not loaded.

What happened instead
Attachment page is loaded.

In what environment (browser/device etc.) does this bug happen/not happen:
Happens in all if lazysizes+unveilhooks is active.

@futtta
Copy link
Author

futtta commented Feb 17, 2020

@futtta futtta changed the title Unveilhooks tries to load image in data-link as css Unveilhooks tries to load page in data-link as css Feb 17, 2020
@futtta
Copy link
Author

futtta commented Mar 25, 2020

I'm working on Autoptimize 2.7, in which I am going to fix this with a small workaround by excluding img tags from honoring data-link attributes in unveilhooks, changing

    tmp = target.getAttribute('data-link');
    if(tmp){
        addStyleScript(tmp, true);
    }

into

    tmp = target.getAttribute('data-link');
    if(tmp && target.tagName.toLowerCase != 'img'){
        addStyleScript(tmp, true);
    }

@aFarkas
Copy link
Owner

aFarkas commented Nov 30, 2020

@futtta
The probably best way to fix this issue is to "namespace" every attribute or make them configurable, but I fear it is too late for that as a default.

Maybe as a workaround I could introduce a variable

@futtta
Copy link
Author

futtta commented Dec 1, 2020

a variable by which to exclude? that would indeed work I guess.

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