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

Fix matching of HTML attributes in filter_images() #54

Open
jan-san opened this issue Jul 10, 2019 · 1 comment
Open

Fix matching of HTML attributes in filter_images() #54

jan-san opened this issue Jul 10, 2019 · 1 comment
Labels
bug topic:img Issues related to the lazy loading of img tags

Comments

@jan-san
Copy link
Collaborator

jan-san commented Jul 10, 2019

The code used to replace srcset and sizes attributes is overly simple and can cause issues like replacing parts of the src or other unrelated attributes:

// also replace the srcset (responsive images)
$replaceHTML = str_replace( 'srcset', 'data-lazy-srcset', $replaceHTML );
// replace sizes to avoid w3c errors for missing srcset
$replaceHTML = str_replace( 'sizes', 'data-lazy-sizes', $replaceHTML );

To fix this, we need to implement a proper parsing of the HTML tag and its attributes.

The issue was reported on wordpress.org: https://wordpress.org/support/topic/broken-image-10/

@jan-san jan-san added bug topic:img Issues related to the lazy loading of img tags labels Jul 10, 2019
@jan-san
Copy link
Collaborator Author

jan-san commented Jul 10, 2019

This issue will become obsolete with #58.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug topic:img Issues related to the lazy loading of img tags
Projects
None yet
Development

No branches or pull requests

1 participant