Add/abstract filtering of tags#9
Conversation
- Add filter for each tag. - Make it easy to filter other tags and/or add more attributes in the future.
|
Looking at this again, code is good but wondering if this functionality should be added in the first place :) It allows "searching" the content for any (opening) HTML tags, then runs a tag-specific filter on the found tags. General drawback is that it will only be used to find It may be useful in the future if there's an attribute we'd want to auto-add similarly to "loading", or perhaps to remove an attribute or a class name as a "last resort" fix in some cases. It may also be useful for some plugins as there will be only one |
|
@azaozz I think we can keep this simple for now and limited to |
Yeah, thinking the same. Can add the extended support when it's "really needed" :) |
Makes the implementation a lot more flexible and easier to expand in the future.
wp_add_lazy_load_attributes(). Introduces_wp_filter_html_tags()that makes it possible to search for any tag, and fires a filter depending on the tag name.wp_get_tags_to_filter()that has a filterable list of the default tags (currently onlyimg).wp_add_lazy_loading_to_img_tags()used with the new filterwp_filter_img_tagsfired when img tags are found in_wp_filter_html_tags().See #4.