This repository was archived by the owner on Dec 23, 2020. It is now read-only.
This repository was archived by the owner on Dec 23, 2020. It is now read-only.
Consider changing or removing wp_get_lazy_load_tags() #5
Closed
Description
Follow up from #3.
PR: #7.
Seems that iframes will not support the loading
attribute for now. Support will be added in the future.
Generally this would mean refactoring or even dropping the existing wp_get_lazy_load_tags()
. It may be "nice to have" a way to globally disable auto-adding of that attribute on the front-end, but not sure that's needed. Ideally there should be a way to change/disable it on per-case (per-image) basis that is also "simple enough" to use to globally disable it in all cases.
As far as I see there are couple of ways to do that:
- Introduce a filter that will run on adding the attribute to each
<img>
tag, and passes some context where that tag is. This will also allow plugins to "fine-tune" where the attribute is added and/or make it conditional on the context. Possible downside is that such filter will be quite "noisy". It will run anywhere form 10-15 times up to few hundred times per page load (in case of big galleries, etc.). - Keep
wp_get_lazy_load_tags()
as a "wrapper" function that will only run the'wp_get_lazy_load_tags'
filter (similarly to how it works now but without support for iframes). In this case it can be extended in the future when iframes start to support the "loading" attribute. Ideally it should also pass some context, for examplecurrent_filter()
or a hard-coded value when it is called "by hand" like fromget_avatar()
, etc.