Wodpress Tutorials

WordPress image lazy loading implementation

WordPress has added the wp_filter_content_tags capacity to the_content interface, which does three fundamental things.

Adds width and stature ascribes to picture labels that don’t have them, in light of the picture ID.

Adds the srcset quality to picture labels dependent on the picture ID.

Adds the loading=”lazy” quality to the picture tag.

The third point is to accomplish lethargic stacking of pictures, the particular capacity is wp_img_tag_add_loading_attr, which takes the picture labels got toward the front and decides individually whether there are width and tallness ascribes, in the event that there are, add loading=”lazy” quality.

Moreover, WordPress additionally gives two interfaces identified with sluggish stacking.

wp_img_tag_add_loading_attr: the worth of the stacking quality, the default is sluggish is apathetic stacking, you can likewise transform it to excited by $img, that is, prompt stacking.

wp_lazy_loading_enabled: regardless of whether to empower lethargic stacking, the default is valid empowered, can likewise be changed to bogus, don’t utilize.

Leave a Reply