Skip to content
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
@azaozz

Description

@azaozz

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 example current_filter() or a hard-coded value when it is called "by hand" like from get_avatar(), etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions